-
Notifications
You must be signed in to change notification settings - Fork 817
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
Fix SSE client handling of nested path URLs #386
base: main
Are you sure you want to change the base?
Conversation
Fix issue with SSE client failing when connecting to servers with nested paths (e.g., http://domain/path1/path2/sse). Previously, the client worked only with simple URLs like http://domain/sse. The fix extracts the base path segment between domain and /sse endpoint using regex, then correctly constructs the response URL by preserving the path structure. This ensures proper communication with MCP servers hosted under non-root paths. Without this fix, clients couldn't connect to SSE servers deployed under nested paths, as the endpoint URLs for posting messages were constructed incorrectly.
Thank you very much @danilpavlov!!! You saved my day with your PR. I hope it will be merged soon. |
Nice! Just wanted to add that using this alongside langchain's adapters that use the
Please note that I also had to change the urljoin
|
Please see danilpavlov#1 @danilpavlov |
fixing /mcp case prefix on langchain
Thank you @jonathanglima so much for that feature! |
@dsp-ant Can you please check this PR. Forget to mark as reviewer :/ |
Fix SSE client failing when connecting to servers with nested paths (e.g., http://domain/path1/path2/sse). Previously, the client worked only with simple URLs like http://domain/sse.
The fix extracts the base path segment between domain and /sse endpoint using regex, then correctly constructs the response URL by preserving the path structure. This ensures proper communication with MCP servers hosted under non-root paths.
Without this fix, clients couldn't connect to SSE servers deployed under nested paths, as the endpoint URLs for posting messages were constructed incorrectly.
Motivation and Context
I got problem while deploying my MCP server inside a Kubernetes cluster. The SSE client was only working with simple URLs like http://example-domain/sse, but failed to properly handle more complex paths such as http://example-domain/path1/path2/sse.
When the server was deployed under nested paths, the client couldn't establish a proper connection because it was incorrectly constructing the endpoint URLs for posting messages. This made it impossible to use MCP servers hosted under non-root paths, which is a common scenario in Kubernetes environments where services often run behind path-based routing.
How Has This Been Tested?
I ve tested on version for local mcp server (http://localhost:8000/sse) and with special mask (http://domain/dummy/sse)
Types of changes
Checklist