René's URL Explorer Experiment


Title: Add mount_path support for proper SSE endpoint routing with multiple FastMCP servers by tim-watcha · Pull Request #540 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Add mount_path support for proper SSE endpoint routing with multiple FastMCP servers by tim-watcha · Pull Request #540 · modelcontextprotocol/python-sdk

X Title: Add mount_path support for proper SSE endpoint routing with multiple FastMCP servers by tim-watcha · Pull Request #540 · modelcontextprotocol/python-sdk

Description: Add mount_path capability to FastMCP for proper SSE endpoint handling when mounted under sub-paths Motivation and Context When multiple FastMCP servers are mounted under different sub-paths in a single Starlette application, the session URIs were being generated incorrectly. FastMCP would create session URIs that didn't include the mount path, causing clients to send messages to the wrong endpoint. This change fixes the issue by adding a mount_path setting that properly normalizes URIs. How Has This Been Tested? Added unit tests for the path normalization function Added unit tests for SSE app creation with different mount paths Tested with a real application mounting multiple FastMCP servers under different paths Manually verified session URI generation and message routing Breaking Changes None. This is backwards compatible with existing code. The new mount_path setting defaults to "/". Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context The issue occurs because the SseServerTransport class creates a session URI without considering that the server might be mounted under a sub-path. The fix adds a mount_path setting to FastMCP and implements a path normalization helper method that combines the mount path with the message path to ensure correct URI generation. This solution maintains clean separation between FastMCP and SseServerTransport without requiring changes to the SseServerTransport class itself.

Open Graph Description: Add mount_path capability to FastMCP for proper SSE endpoint handling when mounted under sub-paths Motivation and Context When multiple FastMCP servers are mounted under different sub-paths in a si...

X Description: Add mount_path capability to FastMCP for proper SSE endpoint handling when mounted under sub-paths Motivation and Context When multiple FastMCP servers are mounted under different sub-paths in a si...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/540

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:cfeffb5e-88bf-6f3c-5313-a1532a27d52c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id871C:11F254:494B75:682171:6A630B9D
html-safe-noncea33e951beb0b7faab9986166ad95ec41d55500485f61993159d51d52b2e85dc6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzFDOjExRjI1NDo0OTRCNzU6NjgyMTcxOjZBNjMwQjlEIiwidmlzaXRvcl9pZCI6Ijc2NzM5NzcwMDA1MTc4OTcxMTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2e1d99b54674b08c576a444668aa52c98de1e59d347d34efd31d482f80936ff3
hovercard-subject-tagpull_request:2469354579
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/540/files
twitter:imagehttps://avatars.githubusercontent.com/u/92134765?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/92134765?s=400&v=4
og:image:altAdd mount_path capability to FastMCP for proper SSE endpoint handling when mounted under sub-paths Motivation and Context When multiple FastMCP servers are mounted under different sub-paths in a si...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb48e7bf0b1945d51f303503b057abf666ce74c3efbe107b413db2bb921c3f012
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9370f37042c29822d6ba7e3f670f0036a0155b21
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/540/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F540%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F540%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 270 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 317 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
ihrprhttps://github.com/ihrpr
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
tim-watcha:fix/sse-server-message-pathhttps://github.com/tim-watcha/mcp-python-sdk/tree/fix/sse-server-message-path
Conversation 24 https://github.com/modelcontextprotocol/python-sdk/pull/540
Commits 17 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits
Checks 0 https://github.com/modelcontextprotocol/python-sdk/pull/540/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/540/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
Add mount_path support for proper SSE endpoint routing with multiple FastMCP servers https://github.com/modelcontextprotocol/python-sdk/pull/540/files#top
Show all changes 17 commits https://github.com/modelcontextprotocol/python-sdk/pull/540/files
9325779 Add mount_path support to FastMCP for proper SSE endpoint handling tim-watcha Apr 19, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/9325779b4eca822d036c190b0aba2652a060c78e
c4c05e1 Add tests for mount_path and path normalization in FastMCP tim-watcha Apr 19, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/c4c05e1bd964fe1bbe91882ed045231b28ba4b2a
d5bd5fd Add multi-server mounting example to README tim-watcha Apr 19, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/d5bd5fdb9925929b7a1694807f7ed78f71910627
dfdf077 Fix line length issue in server.py tim-watcha Apr 19, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/dfdf077aa985d7f20ecb0a51bdcf96c2765f4dae
d9d6bfe Merge branch 'main' into fix/sse-server-message-path tim-watcha Apr 28, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/d9d6bfe5a0f50692e98fe4a60a4eec940d3b7104
1bd89ff Add mount_path parameter to sse_app method tim-watcha Apr 28, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/1bd89ff3497632943de84d0ac1e2455e4d19a037
30b38f9 Apply ruff formatting to test_server.py tim-watcha Apr 28, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/30b38f96bd2c506d2ee82a8718de76af3ca3e751
e248cb3 Fix README.md code example formatting for CI tests tim-watcha Apr 28, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/e248cb3c9922b2d9db3771dd7da16b7c1cb0506a
a5bfdfa Merge branch 'main' into fix/sse-server-message-path tim-watcha May 1, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/a5bfdfa42942ab6f14a8b59c4acfd7c71275c242
e176a7b Merge branch 'main' into fix/sse-server-message-path tim-watcha May 3, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/e176a7b2b6d2a14781f830ff7f3a14e1bd5e56b4
d34f446 Rename variable for clarity in message endpoint handling. tim-watcha May 3, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/d34f4462158d6bb0c710c076e986f95750792a98
e53a22e Update src/mcp/server/fastmcp/server.py tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/e53a22e96a4fc232e4fbd70fe7ab92a4546cceb8
a443362 Update src/mcp/server/fastmcp/server.py tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/a4433622d76bfe5160eba60dfc7aea8203de355d
a53a0a4 Update src/mcp/server/fastmcp/server.py tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/a53a0a477054d09713d123f77349c30d32e14cd9
a40cbef Update src/mcp/server/fastmcp/server.py tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/a40cbefab412371624f5f352255b538b3ef989ba
a431957 Merge branch 'main' into fix/sse-server-message-path tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/a43195736bba0813a068893430ef4c7b2116dd52
0366f68 Fix type hints for mount_path parameter in run method tim-watcha May 7, 2025 https://github.com/modelcontextprotocol/python-sdk/pull/540/commits/0366f68491910cce84b3e694658b68ac2865fe2f
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/540/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/540/files
README.md https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
server.py https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
test_server.py https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
README.mdhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
View file https://github.com/tim-watcha/mcp-python-sdk/blob/0366f68491910cce84b3e694658b68ac2865fe2f/README.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/540/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
src/mcp/server/fastmcp/server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
View file https://github.com/tim-watcha/mcp-python-sdk/blob/0366f68491910cce84b3e694658b68ac2865fe2f/src/mcp/server/fastmcp/server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/540/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-14a2991a8f2be5b9e60dab5fae92d2230dc23e57937ad5e5641b832d9c662738
tests/server/fastmcp/test_server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
View file https://github.com/tim-watcha/mcp-python-sdk/blob/0366f68491910cce84b3e694658b68ac2865fe2f/tests/server/fastmcp/test_server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/540/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
https://github.com/modelcontextprotocol/python-sdk/pull/540/files#diff-2c82340ecf6b6a4c0adbc7f94f272d810dca759a8bba8c3066b4110afc2fd586
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.