Skip to content

Revert mount_path parameter from FastMCP - #1881

Merged
Kludex merged 3 commits into
mainfrom
revert-mount-path-parameter
Jan 16, 2026
Merged

Revert mount_path parameter from FastMCP#1881
Kludex merged 3 commits into
mainfrom
revert-mount-path-parameter

Conversation

@Kludex

@KludexKludex commented Jan 16, 2026

Copy link
Copy Markdown
Member

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 issueroot_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:

fromstarlette.applicationsimportStarlettefromstarlette.routingimportMountfrommcp.server.fastmcpimportFastMCPfrommcp.client.sseimportsse_clientfrommcp.client.sessionimportClientSession# Create MCP servermcp=FastMCP("GitHub API")
@mcp.tool()defhello() ->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:asyncwithsse_client("http://localhost:8000/github/sse") asstreams:
asyncwithClientSession(*streams) assession:
result=awaitsession.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.

@Kludex
Kludexforce-pushed the revert-mount-path-parameter branch from 8d29bae to 41f3219CompareJanuary 16, 2026 10:32
The mount_path parameter added in PR #540 was redundant because the
SSE transport already handles sub-path mounting via ASGI's standard
root_path mechanism.
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).
This revert removes:
- 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 and redundant documentation
The README documentation is updated to show the correct way to mount
multiple MCP servers at different sub-paths, which works out of the box.
@Kludex
Kludexforce-pushed the revert-mount-path-parameter branch from 41f3219 to 9904d65CompareJanuary 16, 2026 10:47
@KludexKludex changed the title Revert mount_path parameter from FastMCPRevert mount_path parameter from FastMCPJan 16, 2026
felixweinberger
felixweinberger previously approved these changes Jan 16, 2026

@felixweinbergerfelixweinberger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but do we need a migration.md line about removing this?

I think it's a breaking change to remove the mount_path argument if someone was using it (even if it was redundant / did nothing).

@Kludex
Kludex enabled auto-merge (squash) January 16, 2026 13:19
@Kludex
Kludex merged commit edf0950 into mainJan 16, 2026
26 checks passed
@Kludex
Kludex deleted the revert-mount-path-parameter branch January 16, 2026 13:23
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Kludex@felixweinberger