Skip to content

Fix: Fix MCP_PROXY_FULL_ADDRESS base path handling for SSE message endpoint #707

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ronantakizawa
Copy link

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 respects
the 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. When MCP_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 failing
with 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 message
endpoints, ensuring SSE transport works correctly with reverse proxy deployments.

Before (Broken):

  • ✅ SSE requests: https://example.com/inspector/mcp_proxy/sse (correct)
  • ❌ Message requests: https://example.com/message (incorrect - base path stripped)

After (Fixed):

  • ✅ SSE requests: https://example.com/inspector/mcp_proxy/sse
  • ✅ Message requests: https://example.com/inspector/mcp_proxy/message

How Has This Been Tested?

  • Unit Tests: All existing tests pass (289/289 client tests)
  • Build Verification: Full build pipeline successful
  • Logic Verification: Tested path extraction logic with various URL formats:
    • No env var → /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
  • Integration Testing: Verified server starts correctly with base path configuration

Breaking Changes

None. This is a backward-compatible bug fix:

  • Existing deployments without MCP_PROXY_FULL_ADDRESS continue working unchanged
  • Only affects SSE message endpoint path construction when base path is configured

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant