-
Notifications
You must be signed in to change notification settings - Fork 771
fix: preserve custom paths in SSE endpoint URLs #466
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
Conversation
should we include those filing tests in this PR |
When an SSE client connects with a custom path (e.g., /api/v1/custom/sse), ensure the endpoint URL maintains the same base path structure but with /messages instead of /sse. This fixes issues where custom endpoints were getting collapsed to the root path. Should fix issues reported in modelcontextprotocol/inspector#313 and #296 Tests demonstrating the issue were added in PR #439 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
39629e2
to
2f522bf
Compare
@ihrpr brought the tests over - note, dropped the change to package-lock.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ihrpr do you have a plan for this release? |
As a heads up, this breaks SSE integrations with mcp.run – we were sending the full SSE endpoint down to support the python-sdk and now the endpoint pathname is being rewritten to |
@chrisdickinson thanks for catching - #504 should fix, though it couldn't hurt to verify [edit: not that simple, reverted path preservation and will revisit] |
Summary
When an SSE client connects with a custom path (e.g.,
/api/v1/custom/sse
), ensure the endpoint URL maintains the same base path structure but with/messages
instead of/sse
. This fixes issues where custom endpoints were getting collapsed to the root path.Problem
The SSE client was not preserving custom paths when constructing endpoint URLs. When a client connected to a server at a custom path like
/api/v1/custom/sse
, the endpoint URL would be constructed without preserving the custom path, resulting in POST requests being sent to/messages
instead of/api/v1/custom/messages
.Solution
Modified the endpoint event handler in the SSE client to:
/sse
suffix)/messages
suffixTesting
This PR makes the failing tests from #439 pass. The tests verify that:
Related Issues
Test Plan
🤖 Generated with Claude Code