-
Notifications
You must be signed in to change notification settings - Fork 1.6k
SSE does not work on nested routes #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have met the same problem. This issue has been closed, did you find a solution? |
Hello - yes For SSE - I had to monkey patch mcp.server.sse.SseServerTransport's connect_sse method. Somewhere in the middle add your route parts into the root_path variable, for me the patch is
In theory you can use some middleware as well in the starlette application and update the root_path in the scope there, but I just could not get that working yet properly. I'll reopen this issue, as hoping for some guidance as well from maintainers, especially since this method just was updated and still does not work for our use-case properly. |
Thanks for your reply, I just found there is already a PR trying to resolve this, and I also found the official approach #540. I think these might be helpful. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
URL parts are being omitted on SSE client session connect.
INFO:mcp.client.sse:Connecting to SSE endpoint: https://url-part1.url-part2.com/route1/route2/sse
INFO:httpx:HTTP Request: GET https://url-part1.url-part2.com/route1/route2/sse "HTTP/1.1 200 OK"
INFO:mcp.client.sse:Received endpoint URL: https://url-part1.url-part2.com/route2/messages/?session_id=a2bd62740b69466c8b27043ccda2513f
INFO:mcp.client.sse:Starting post writer with endpoint URL: https://url-part1.url-part2.com/route2/messages/?session_id=a2bd62740b69466c8b27043ccda2513f
To Reproduce
Expected behavior
route1 is not omitted
Desktop (please complete the following information):
Additional context
issue stems from:
.venv/lib/python3.12/site-packages/mcp/client/sse.py line 66
The text was updated successfully, but these errors were encountered: