-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Describe the bug
When I setup MCP server as a SSE app under some subpath in existing ASGI app, in response to /my/sub/path/sse, I receive wrong endpoint path in data: (missing /my/sub/path prefix). For example if SSE app is mounted under /mcp/test and I call /mcp/test/sse in response I receive:
$ curl -i localhost:8080/mcp/test/sse
...
event: endpoint
data: /messages/?session_id=e01cc317d1cd48fdb305a8074cee2134
Then MCP client tries to call http://localhost:8080/messages/?session_id=e01cc317d1cd48fdb305a8074cee2134 which does not exist. I believe this is not an issue if MPC server is mounted under root path /, but with subpath it is returning wrong data path.
Side note: There is example of this process in this repo readme but what is the point of mounting app into existing asgi server under /? It will override all routes of existing app, no?
To Reproduce
from fastapi import FastAPI
from mcp.server import FastMCP
# Create a server instance
server = FastMCP("quoting-mcp")
app = FastAPI()
app.mount('/mcp/test', server.sse_app())call http://localhost:8080:/mcp/test/sse
Expected behavior
$ curl -i localhost:8080/mcp/test/sse
...
event: endpoint
data: /mcp/test/messages/?session_id=e01cc317d1cd48fdb305a8074cee2134