You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sse_client fails if URL is not on the root path #563
urljoin discards the whole path, meaning that if url is http://localhost:8000/mcp/sse and sse.data is /messages/?session_id=123 we get endpoint_url == "http://localhost:8000/messages/?session_id=123" instead of http://localhost:8000/mcp/messages/?session_id=123
To Reproduce
Launch an MCP server with SSE on a path different from the root of the application.
As far as I understand, the main use case is to have multiple MCP servers managed within a single Starlette/FastAPI server. Here, setting sse_path and message_path will only work when a single FastMCP is bound to "/". However, since we can't bind multiple FastMCP apps to the same path the core issue remains. For example:
When connecting to app1, the proper path is returned in data. Unfortunately app1's path is absolute w.r.t. the server root and will only work when binding to /:
IMO the right solution is not in the client but within FastMCP. I remember seeing a thread on the proper implementation somewhere, I'l link back when I find it.
Activity
TheCulliganMan commentedon Apr 22, 2025
The setup is a bit strange here, but setting the
sse_pathandmessage_pathin your FastMCP instantiation does allow for this behavior.python-sdk/src/mcp/server/fastmcp/server.py
Lines 75 to 76 in babb477
theobjectivedad commentedon Apr 23, 2025
As far as I understand, the main use case is to have multiple MCP servers managed within a single Starlette/FastAPI server. Here, setting
sse_pathandmessage_pathwill only work when a single FastMCP is bound to "/". However, since we can't bind multiple FastMCP apps to the same path the core issue remains. For example:When connecting to app1, the proper path is returned in
data. Unfortunately app1's path is absolute w.r.t. the server root and will only work when binding to/:IMO the right solution is not in the client but within FastMCP. I remember seeing a thread on the proper implementation somewhere, I'l link back when I find it.
theobjectivedad commentedon Apr 23, 2025
#412
theobjectivedad commentedon Apr 23, 2025
One more - looks like there is already a PR open for the proper fix: #540
felixweinberger commentedon Oct 3, 2025
Closing as I believe this is resolved by #540