Skip to content

fix: STDIO and SSE transports need MCP_FULL_PROXY_ADDRESS #708

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 3 commits into
base: main
Choose a base branch
from

Conversation

richardkmichael
Copy link
Collaborator

@richardkmichael richardkmichael commented Aug 12, 2025

Motivation and Context

#630

The MCP client needs to know the full path to the proxy server when opening the SSE transport for STDIO and SSE endpoints.

The client knows where it expects to see the server, so pass this to the server, to use when building the endpoint.

How Has This Been Tested?

Start nginx as proxy for the backed. Using an nginx proxy: nginx -c inspector.conf (below).

Open the Inspector, set the Inspector Proxy Address to a URL through nginx: http://localhost:9000/mcp/inspector/backend.

# inspector.conf

daemon off;
error_log /dev/stdout info;
events {
}

http {
    upstream inspector-backend {
        server [::1]:6277;
        server 127.0.0.1:6277;
    }

    # Inspector backend only
    server {
        listen 9000;
        listen [::]:9000;

        server_name localhost;

        location /mcp/inspector/backend/ {
            proxy_pass http://inspector-backend/;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_buffering off;
            proxy_cache off;
            proxy_read_timeout 24h;
            proxy_set_header X-Accel-Buffering no;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }
}

Breaking Changes

No

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

There are other ways to fix this, but my hunch is treating the client as authoritative will be most flexible different deployment scenarios, and also prevent a server-side / client-side configuration mismatch.

Also, I'd add a server test for this, but there are no server tests at the moment. Are server tests desired?

Issue #437 is related, for which there is a fix in a fork, not yet submitted as a PR. It looks like the right approach, appending to the query params from the env. This would close out the current proxy-related issues.

@richardkmichael richardkmichael changed the title fix: STDIO and SSE transports need MCP_FULL_PROXY_PATH fix: STDIO and SSE transports need MCP_FULL_PROXY_ADDRESS Aug 12, 2025
@olaservo
Copy link
Member

olaservo commented Aug 20, 2025

Hi @richardkmichael I was testing this out and saw that there was a build error: https://github.com/modelcontextprotocol/inspector/actions/runs/17087872859/job/48455657789?pr=708

For future branches, this shouldn't be an issue since we added a precommit hook to format using prettier.

@richardkmichael
Copy link
Collaborator Author

richardkmichael commented Aug 20, 2025

Hi @richardkmichael I was testing this out and saw that there was a build error: https://github.com/modelcontextprotocol/inspector/actions/runs/17087872859/job/48455657789?pr=708

For future branches, this shouldn't be an issue since we added a precommit hook to format using prettier.

I believe the merge has caused this, but I will look closer. My local branch passes, and the commits I pushed also pass. Prettier fails on the CI jobs launched following the merge commits.

https://github.com/modelcontextprotocol/inspector/pull/708/commits

I have also noticed that the prettier which runs in the build action is not the same version as the project (package-lock.json). The build action runs npx prettier --check prior to package installation, which means it will run latest prettier (seen installing). I expect this won't likely cause a problem, but it's conceivable. I think the best approach, for everyone but especially maintainers (so that the bottleneck and burden don't fall to them), would be to always use the same version and configuration of prettier everywhere.

What do you think? I was intending to send a PR to adjust the CI build action.

@richardkmichael
Copy link
Collaborator Author

Looks like it was bad resolution of the merge conflict. Is a tool doing this integration?

 pull/708 $= $ git log -3 --oneline -- client/src/lib/hooks/__tests__/useConnection.test.tsx
ea9ab9f Merge branch 'main' into fix-630
74900fc feat: unify OAuth scope discovery between automatic and manual flows
d31ab36 Add tests for MCP_PROXY_FULL_ADDRESS SSE endpoint support
 main $= $ git checkout --detach d31ab36
HEAD is now at d31ab36 Add tests for MCP_PROXY_FULL_ADDRESS SSE endpoint support

 (d31ab36...) $ $ git merge 74900fc
Auto-merging client/src/lib/hooks/__tests__/useConnection.test.tsx
CONFLICT (content): Merge conflict in client/src/lib/hooks/__tests__/useConnection.test.tsx
Auto-merging client/src/lib/hooks/useConnection.ts
Recorded preimage for 'client/src/lib/hooks/__tests__/useConnection.test.tsx'
Automatic merge failed; fix conflicts and then commit the result.

Probably easiest if I rebase to main and sort out the conflict.

@richardkmichael
Copy link
Collaborator Author

@olaservo I was thinking to rebase, if you don't need this ref. That way, there's no "patch" commit, resolving the merge error.

richardkmichael and others added 3 commits August 21, 2025 23:11
The STDIO and SSE transports use SSE between the client and the proxy
server.  SSE requires the client to initiate the MCP conversation
(event-stream) at the endpoint provided by the server.  The endpoint
provided by the server must obey where the client sees the server,
rather than being assumed to be server-root `/message`.

The Streamable HTTP endpoint does not need the full proxy address
because the response is an event-stream directly, and does not use SSE.
Tests verify that proxyFullAddress query parameter is sent for both
STDIO and SSE transports, but not Streamable HTTP, when
MCP_PROXY_FULL_ADDRESS is configured.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

2 participants