You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCPServerEntry response headers get swallowed by VirtualMCPServer #6743
In a setup where we have VirtualMCPServer and MCPServerEntry's, response headers sent by the upstream server seem to be swallowed by the VirtualMCPServer.
Example tool that throws:
mcpRouter.all('/mcp', async (ctx, _) => {
const body = ctx.request.body;
const isToolCall =
typeof body === 'object' && body !== null && 'method' in body && body.method === 'tools/call';
if (isToolCall) {
ctx.status = 403;
ctx.set(
'WWW-Authenticate',
'Bearer error="insufficient_scope", error_description="mcp header experiment", scope="mcp.write"',
);
ctx.body = {
error: 'insufficient_scope',
error_description: 'mcp header experiment',
};
return;
}
// SNIP
});
When calling straight to the server responds as such:
I couldn't find any configuration options to allow for passthrough response headers, only passthrough request headers. Could this be something that could be added to the project? I'm also willing to contribute if this ranks low in your current priorities.
changed the title [-]McpServer response headers get swallowed by VMcpServer[/-][+]MCPServerEntry response headers get swallowed by VirtualMCPServer[/+]on Oct 2, 2026
Thanks for reporting this, @JeremiasRy , and for offering to contribute! Assigning this to you.
The current vMCP code does lose upstream WWW-Authenticate scope challenges. This needs a bit of design around vMCP auth before implementation: incoming client authentication and outgoing backend authentication are separate, so we need to agree on how backend scope challenges should reach the client.
Could you share your operator/vMCP version, redacted manifests and auth configuration, and the full downstream response body? That will help clarify the setup and the reported 403.
Happy to work and address through the design with you before you start a PR.
cc @jerm-dro@jhrozek as the vMCP owner, for input on the auth behavior and proposed approach.
Hi guys, @Sanskarzz, @jerm-dro , @jhrozek. The reason why we try this approach return insufficient_scope from upstream server is because we try to follow step-up scope challenge here. And this seems like the easiest way to support it
However, as I can see toolhive has defined OAuthErrInsufficientScope but couldn’t find it used in the Cedar authorization-denial path. Do we have expected timeline to support step-up scope challenge in production for toolhive? 🤔
Thanks for clarifying, @dqk0902—the step-up authorization use case makes sense.
You’re right: OAuthErrInsufficientScope is currently defined but isn’t wired into an end-to-end step-up flow. Cedar denials also don’t identify which OAuth scopes would satisfy the request. A denial can reflect other policy restrictions, so returning insufficient_scope for every Cedar denial would be misleading.
For backend scope challenges, we still need to define how the required scopes and authorization-server metadata map across vMCP’s incoming and outgoing authentication boundaries.
I don’t have a confirmed production ETA to share yet. cc @reyortiz3@jhrozek for input on the design and prioritization.
Could you share the redacted auth configuration and clarify which authorization server issues mcp.write? That would help us agree on a concrete flow for contribution.
@JeremiasRy, are you still interested in contributing to this? I’m happy to help move it forward by preparing a design proposal for vMCP scope challenges and step-up authorization.
If you’re still interested, we can coordinate on the design and implementation. If you’re no longer available, I’m happy to take over.
We operate our own authorization server in the architechture. It issues the access tokens and OAuth scopes used to authenticate clients to our ToolHive gateway. mcp.write was just an example scope so we can test scope challenge flow.
A denial can reflect other policy restrictions, so returning insufficient_scope for every Cedar denial would be misleading.
I agree, we might not want to return insufficient_scope for every Cedar denial.
Could VirtualMCPServer support an explicit configuration mapping tools to required scopes? When the incoming token lacks those scopes, vMCP could return a 403 with a WWW-Authenticate scope challenge. Requests with sufficient scopes would still undergo Cedar authorization, and other policy denials would remain ordinary denials.
@Sanskarzz , Hi!
Hope this information helpful for you guys. So for scope challenge, we as MCP Gateway/Server need to return MCP standard spec: 403 + WWW-authenticate + insufficient_scope, but this currently do not worked for Codex/ChatGPT.
Codex/ChatGPT only works with 200 + _meta["mcp/www_authenticate"] (OpenAI docs)
So you can see, we have different logic to trigger reauth from client when handle scope challenge. For example, cloudfare, they have to write this kind of identifying client logic to handle it (cloudfare code). But this is the mismatch from MCP Client side!
@JeremiasRy, are you still interested in contributing to this? I’m happy to help move it forward by preparing a design proposal for vMCP scope challenges and step-up authorization.
If you’re still interested, we can coordinate on the design and implementation. If you’re no longer available, I’m happy to take over.
@Sanskarzz Jeremias is currently on leave (we're in the same team) so it'd be great if you can reassign this. This is currently very critical to us as without this support, we won't be able to take advantage of the step-up scope challenge implementation as recommended in the MCP spec. Thanks a lot for your work on Toolhive!
Thanks @ngocketit for confirming, and @dqk0902 for the additional detail. I’ve assigned myself and will take this forward.
The external-AS clarification gives us a concrete initial direction: opt-in mappings from exposed tools to required scopes in the validated incoming token, returning a standard 403 + WWW-Authenticate scope challenge before execution. Cedar would remain authoritative, with ordinary policy denials retaining their existing behavior.
The client compatibility distinction is useful. I propose standard HTTP behavior by default, with any OpenAI compatibility mode explicit and tested against named client versions.
Really nice!! @Sanskarzz , I agree we should have default 403 + WWW-Authenticate, some small questions for the other mode:
I propose standard HTTP behavior by default, with any OpenAI compatibility mode explicit and tested against named client versions.
Do you have plan to support this 🤔 Because, from my own experience, identify which clients is Codex/ChatGPT is not that easy and kinda hacky (in authorization server layer). If we can support this 200 + _meta mode in Toolhive layer that would be best, because at least I can see from the logs when MCP client do initialize, we saw "clientInfo":{"title":"Codex","version":"etc etc","name":"codex-mcp-client"}} which mean in toolhive layer, we can identify whether the client is Codex/ChatGPT and also the version
@dqk0902 Thanks for the clarification! I’ve included an explicit responseMode: tool-result option for 200 + _meta, while keeping 403 + WWW-Authenticate as the default. Both modes enforce the same scope check before execution. I’ve kept selection in configuration because Modern stateless requests do not require initialization. Wire behavior is covered by tests; authentication UI still needs verification against specific client versions.
Hi @Sanskarzz, Thanks! I have 1 small question for clarification with current approach
I’ve included an explicit responseMode: tool-result option for 200 + _meta, while keeping 403 + WWW-Authenticate as the default.
I have gone thru your PR here Am I understand correctly that toolhive will support default 403 + WWW-Authenticate to everybody and if we change the responseMode to tool-result option for 200 + _meta then it will switch the whole gateway to return 200 + _meta for everybody?
I’ve kept selection in configuration because Modern stateless requests do not require initialization.
As reading your PR, it means toolhive will have option to return 403 + WWW-Authenticateor 200 + _meta based on configuration? So for example, in our logic would have to identify who are Codex/ChatGPT and configure that to use 200 + _meta 🤔
Thanks @dqk0902—you’re right that a gateway-wide toggle alone wouldn’t cover mixed clients on the same URL.
For the transport follow-up, I propose an opt-in responseMode: auto. ToolHive would select the scope-challenge format per client: recognized, tested client profiles requiring tool-result authentication would receive 200 + _meta["mcp/www_authenticate"]; other clients would receive the standard 403 + WWW-Authenticate. Missing or unrecognized client information would fall back to HTTP 403.
This would let supported clients share one gateway URL without external routing or client-detection logic in your authorization server. We would use initialization metadata for session-based clients and per-request metadata where available for stateless clients, while retaining explicit http and tool-result overrides.
Both formats would enforce the same Cedar and scope checks before execution. PR #7170 remains the core-enforcement foundation; automatic response selection belongs in the next PR and will need verification against specific client versions.
I propose an opt-in responseMode: auto. ToolHive would select the scope-challenge format per client: recognized, tested client profiles requiring tool-result authentication would receive 200 + _meta["mcp/www_authenticate"]; other clients would receive the standard 403 + WWW-Authenticate
This is great, thanks @Sanskarzz !!! 🚀 Please let me know if you need anything from my side!
Thanks @dqk0902! PR 2 is open: #7190. Could you share your exact Codex/ChatGPT/etc versions and redacted clientInfo showing the name and version sent during initialization? For stateless clients, the per-request client metadata would help.
This will help verify the auto-mode profiles. Once PR 3 adds configuration support, could you also help test the consent prompt, scope upgrade, and successful retry?
Hi @Sanskarzz , we have not testing with ChatGPT yet. The latest Codex version we can capture from our side is "version": "0.166.0-alpha.5.1". However, the latest Codex version in the internet, 0.170.0 release yesterday, seems does not fix this problem yet.
Once PR 3 adds configuration support, could you also help test the consent prompt, scope upgrade, and successful retry?
Yes, I think we can have testing in our dev env by bump toolhive version
Hi @Sanskarzz, really glad to see the progress in this issue! Much appreciated 🙏
I wanted politely to ask that; what is the current status on the finishing PR on this trilogy? We are eager to put this to the test once it's available.
Hi @JeremiasRy
Thank you for bringing this to our attention. I have submitted the final pull request (#7446), and it is currently undergoing review. This issue will be resolved and closed upon merging.
Activity
[-]McpServer response headers get swallowed by VMcpServer[/-][+]MCPServerEntry response headers get swallowed by VirtualMCPServer[/+]Sanskarzz commentedon Oct 4, 2026
Thanks for reporting this, @JeremiasRy , and for offering to contribute! Assigning this to you.
The current vMCP code does lose upstream WWW-Authenticate scope challenges. This needs a bit of design around vMCP auth before implementation: incoming client authentication and outgoing backend authentication are separate, so we need to agree on how backend scope challenges should reach the client.
Could you share your operator/vMCP version, redacted manifests and auth configuration, and the full downstream response body? That will help clarify the setup and the reported 403.
Happy to work and address through the design with you before you start a PR.
cc @jerm-dro @jhrozek as the vMCP owner, for input on the auth behavior and proposed approach.
dqk0902 commentedon Nov 12, 2026
Hi guys, @Sanskarzz, @jerm-dro , @jhrozek. The reason why we try this approach return
insufficient_scopefrom upstream server is because we try to follow step-up scope challenge here. And this seems like the easiest way to support itHowever, as I can see toolhive has defined OAuthErrInsufficientScope but couldn’t find it used in the Cedar authorization-denial path. Do we have expected timeline to support step-up scope challenge in production for toolhive? 🤔
Sanskarzz commentedon Nov 12, 2026
Thanks for clarifying, @dqk0902—the step-up authorization use case makes sense.
You’re right:
OAuthErrInsufficientScopeis currently defined but isn’t wired into an end-to-end step-up flow. Cedar denials also don’t identify which OAuth scopes would satisfy the request. A denial can reflect other policy restrictions, so returning insufficient_scope for every Cedar denial would be misleading.For backend scope challenges, we still need to define how the required scopes and authorization-server metadata map across vMCP’s incoming and outgoing authentication boundaries.
I don’t have a confirmed production ETA to share yet. cc @reyortiz3 @jhrozek for input on the design and prioritization.
Could you share the redacted auth configuration and clarify which authorization server issues
mcp.write? That would help us agree on a concrete flow for contribution.Sanskarzz commentedon Nov 12, 2026
@JeremiasRy, are you still interested in contributing to this? I’m happy to help move it forward by preparing a design proposal for vMCP scope challenges and step-up authorization.
If you’re still interested, we can coordinate on the design and implementation. If you’re no longer available, I’m happy to take over.
dqk0902 commentedon Nov 12, 2026
Thanks @Sanskarzz for replying, for the context
We operate
our own authorization serverin the architechture. It issues the access tokens and OAuth scopes used to authenticate clients to our ToolHive gateway.mcp.writewas just an example scope so we can test scope challenge flow.I agree, we might not want to return insufficient_scope for every Cedar denial.
Could VirtualMCPServer support an explicit configuration mapping tools to required scopes? When the incoming token lacks those scopes, vMCP could return a 403 with a WWW-Authenticate scope challenge. Requests with sufficient scopes would still undergo Cedar authorization, and other policy denials would remain ordinary denials.
dqk0902 commentedon Nov 16, 2026
@Sanskarzz , Hi!
Hope this information helpful for you guys. So for scope challenge, we as MCP Gateway/Server need to return
MCP standard spec:403 + WWW-authenticate + insufficient_scope, but this currently do not worked for Codex/ChatGPT.200 + _meta["mcp/www_authenticate"](OpenAI docs)403 + WWW-authenticate + insufficient_scope(https://claude.com/docs/connectors/building/lazy-authentication#don’t-wrap-the-refusal-in-a-200-tool-error)So you can see, we have different logic to trigger reauth from client when handle scope challenge. For example, cloudfare, they have to write this kind of identifying client logic to handle it (cloudfare code). But this is the mismatch from
MCP Clientside!ngocketit commentedon Nov 16, 2026
@Sanskarzz Jeremias is currently on leave (we're in the same team) so it'd be great if you can reassign this. This is currently very critical to us as without this support, we won't be able to take advantage of the step-up scope challenge implementation as recommended in the MCP spec. Thanks a lot for your work on Toolhive!
Sanskarzz commentedon Nov 16, 2026
Thanks @ngocketit for confirming, and @dqk0902 for the additional detail. I’ve assigned myself and will take this forward.
The external-AS clarification gives us a concrete initial direction: opt-in mappings from exposed tools to required scopes in the validated incoming token, returning a standard 403 + WWW-Authenticate scope challenge before execution. Cedar would remain authoritative, with ordinary policy denials retaining their existing behavior.
The client compatibility distinction is useful. I propose standard HTTP behavior by default, with any OpenAI compatibility mode explicit and tested against named client versions.
dqk0902 commentedon Nov 16, 2026
Really nice!! @Sanskarzz , I agree we should have default
403 + WWW-Authenticate, some small questions for the other mode:200 + _metamode in Toolhive layer that would be best, because at least I can see from the logs when MCP client doinitialize, we saw"clientInfo":{"title":"Codex","version":"etc etc","name":"codex-mcp-client"}}which mean in toolhive layer, we can identify whether the client is Codex/ChatGPT and also the versionSanskarzz commentedon Nov 17, 2026
@dqk0902 Thanks for the clarification! I’ve included an explicit responseMode: tool-result option for 200 + _meta, while keeping 403 + WWW-Authenticate as the default. Both modes enforce the same scope check before execution. I’ve kept selection in configuration because Modern stateless requests do not require initialization. Wire behavior is covered by tests; authentication UI still needs verification against specific client versions.
dqk0902 commentedon Nov 17, 2026
Hi @Sanskarzz, Thanks! I have 1 small question for clarification with current approach
I have gone thru your PR here Am I understand correctly that toolhive will support default
403 + WWW-Authenticateto everybody and if we change the responseMode totool-result option for 200 + _metathen it will switch the whole gateway to return200 + _metafor everybody?As reading your PR, it means toolhive will have option to return
403 + WWW-Authenticateor200 + _metabased on configuration? So for example, in our logic would have to identify who are Codex/ChatGPT and configure that to use200 + _meta🤔Sanskarzz commentedon Nov 17, 2026
Thanks @dqk0902—you’re right that a gateway-wide toggle alone wouldn’t cover mixed clients on the same URL.
For the transport follow-up, I propose an opt-in
responseMode: auto. ToolHive would select the scope-challenge format per client: recognized, tested client profiles requiring tool-result authentication would receive200 + _meta["mcp/www_authenticate"]; other clients would receive the standard403 + WWW-Authenticate. Missing or unrecognized client information would fall back to HTTP 403.This would let supported clients share one gateway URL without external routing or client-detection logic in your authorization server. We would use initialization metadata for session-based clients and per-request metadata where available for stateless clients, while retaining explicit
httpandtool-resultoverrides.Both formats would enforce the same Cedar and scope checks before execution. PR #7170 remains the core-enforcement foundation; automatic response selection belongs in the next PR and will need verification against specific client versions.
Enforce incoming scopes in the vMCP core (#7170)
dqk0902 commentedon Nov 18, 2026
This is great, thanks @Sanskarzz !!! 🚀 Please let me know if you need anything from my side!
Sanskarzz commentedon Nov 19, 2026
Thanks @dqk0902! PR 2 is open: #7190. Could you share your exact Codex/ChatGPT/etc versions and redacted
clientInfoshowing the name and version sent during initialization? For stateless clients, the per-request client metadata would help.This will help verify the auto-mode profiles. Once PR 3 adds configuration support, could you also help test the consent prompt, scope upgrade, and successful retry?
dqk0902 commentedon Nov 19, 2026
Hi @Sanskarzz , we have not testing with ChatGPT yet. The latest Codex version we can capture from our side is
"version": "0.166.0-alpha.5.1". However, the latest Codex version in the internet, 0.170.0 release yesterday, seems does not fix this problem yet.Yes, I think we can have testing in our dev env by bump toolhive version
Cover vMCP scope transport review gaps
Add per-client vMCP scope challenge responses (#7190)
JeremiasRy commentedon Dec 1, 2026
Hi @Sanskarzz, really glad to see the progress in this issue! Much appreciated 🙏
I wanted politely to ask that; what is the current status on the finishing PR on this trilogy? We are eager to put this to the test once it's available.
Sanskarzz commentedon Dec 2, 2026
Hi @JeremiasRy
Thank you for bringing this to our attention. I have submitted the final pull request (#7446), and it is currently undergoing review. This issue will be resolved and closed upon merging.