Title: Revert `mount_path` parameter from `FastMCP` by Kludex · Pull Request #1881 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Revert `mount_path` parameter from `FastMCP` by Kludex · Pull Request #1881 · modelcontextprotocol/python-sdk
X Title: Revert `mount_path` parameter from `FastMCP` by Kludex · Pull Request #1881 · modelcontextprotocol/python-sdk
Description: Summary This PR reverts the mount_path parameter added in #540. The parameter was redundant because the SSE transport already handles sub-path mounting via ASGI's standard root_path mechanism. Why this revert? When using Starlette's Mount("/path", app=mcp.sse_app()), Starlette automatically sets root_path in the ASGI scope. The SseServerTransport already uses this to construct the correct message endpoint path (see sse.py lines 148-161): # From sse.py - this already exists and handles the issue root_path = scope.get("root_path", "") full_message_path_for_client = root_path.rstrip("/") + self._endpoint Minimal Reproducible Example The existing test test_sse_client_basic_connection_mounted_app in tests/shared/test_sse.py already demonstrates this works. Here's a simplified version: from starlette.applications import Starlette from starlette.routing import Mount from mcp.server.fastmcp import FastMCP from mcp.client.sse import sse_client from mcp.client.session import ClientSession # Create MCP server mcp = FastMCP("GitHub API") @mcp.tool() def hello() -> str: return "Hello from GitHub!" # Mount at /github sub-path - NO mount_path parameter needed! app = Starlette(routes=[Mount("/github", app=mcp.sse_app())]) # Run with uvicorn, then connect: async with sse_client("http://localhost:8000/github/sse") as streams: async with ClientSession(*streams) as session: result = await session.initialize() print(f"Connected to: {result.serverInfo.name}") # Works! The SSE transport automatically uses root_path # to return /github/messages/ as the message endpoint The client connects to /github/sse and the server automatically returns /github/messages/ as the message endpoint - no mount_path configuration needed. What's removed mount_path setting from Settings class mount_path parameter from FastMCP.__init__ mount_path parameter from run() and run_sse_async() _normalize_path() helper method mount_path parameter from sse_app() Related tests for the removed functionality What's updated The README documentation now shows the correct way to mount multiple MCP servers, which works out of the box via ASGI's root_path.
Open Graph Description: Summary This PR reverts the mount_path parameter added in #540. The parameter was redundant because the SSE transport already handles sub-path mounting via ASGI's standard root_path mechanism. ...
X Description: Summary This PR reverts the mount_path parameter added in #540. The parameter was redundant because the SSE transport already handles sub-path mounting via ASGI's standard root_path mechani...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/1881
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:08065d3e-1f09-dae6-ff8d-74e6788e7c03 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A710:10EC7:24AA5DF:323B4C1:6A62F84B |
| html-safe-nonce | 8c941a6ae4a7b99a855cf85e02351c1cc42863c1334bc0a3e1ed439ebdda97e0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzEwOjEwRUM3OjI0QUE1REY6MzIzQjRDMTo2QTYyRjg0QiIsInZpc2l0b3JfaWQiOiIyNzgwOTUzNTM4ODIyNjAwNzgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 225f9327d069c12380c030c6b9c905f5a60a93c8a6bf4ab2b8bccfb92a4e4fc0 |
| hovercard-subject-tag | pull_request:3180652948 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/1881/files |
| twitter:image | https://avatars.githubusercontent.com/u/7353520?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/7353520?s=400&v=4 |
| og:image:alt | Summary This PR reverts the mount_path parameter added in #540. The parameter was redundant because the SSE transport already handles sub-path mounting via ASGI's standard root_path mechanism. ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e40dc698184067b40ef2d941585f66ed42711564a879644f984f1eacea129c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b4f544bf80583e749557efd76afda56317b6252d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width