Fix: Fix MCP_PROXY_FULL_ADDRESS base path handling for SSE message endpoint #707
+21
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes inconsistent handling of
MCP_PROXY_FULL_ADDRESS
base paths between SSE and message endpoints.When using a proxy with a base path (e.g.,
/inspector/mcp_proxy
), the SSE endpoint correctly respectsthe full address while the message endpoint incorrectly strips the base path.
Motivation and Context
This change fixes issue #630 where the
MCP_PROXY_FULL_ADDRESS
environment variable is inconsistently handled between SSE and message endpoints, breaking SSE transport functionality when deployed behind reverse proxies with base paths. WhenMCP_PROXY_FULL_ADDRESS
is set to a URL with a base path (e.g.,https://example.com/inspector/mcp_proxy
), the SSE transport becomes completely non-functional due to inconsistent URL construction. This results in SSE connections establishing successfully, but all subsequent message requests failingwith 404 errors because they're sent to the wrong URL.
Solution:
Extract the base path from
MCP_PROXY_FULL_ADDRESS
and apply it consistently to both SSE and messageendpoints, ensuring SSE transport works correctly with reverse proxy deployments.
Before (Broken):
https://example.com/inspector/mcp_proxy/sse
(correct)https://example.com/message
(incorrect - base path stripped)After (Fixed):
https://example.com/inspector/mcp_proxy/sse
https://example.com/inspector/mcp_proxy/message
How Has This Been Tested?
/message
http://localhost:6277
→/message
http://localhost:6277/inspector/mcp_proxy
→/inspector/mcp_proxy/message
http://localhost:6277/inspector/mcp_proxy/
→/inspector/mcp_proxy/message
Breaking Changes
None. This is a backward-compatible bug fix:
MCP_PROXY_FULL_ADDRESS
continue working unchangedTypes of changes
Checklist
Additional context