Describe the bug
This line is the problem:
|
endpoint_url = urljoin(url, sse.data) |
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.
app = FastAPI()
mcp = FastMCP("my-mcp-server")
app.mount("/mcp", mcp.sse_app())
- Try to connect to it using
sse_client as per the tutorial
Expected behavior
endpoint_url should contain the suffix of url with /sse stripped instead of the whole path being stripped.