fix: prevent _auth_ metadata from leaking to upstream MCP servers#325
Merged
fix: prevent _auth_ metadata from leaking to upstream MCP servers#325
Conversation
injectAuthMetadata() was mutating the args map in-place, causing _auth_* fields to be forwarded to upstream servers via CallTool(). FastMCP-based servers using Pydantic's validate_call reject unknown keyword arguments, breaking tool calls for authenticated users. Fix: injectAuthMetadata() now returns a shallow copy. All call sites use separate activityArgs for logging and clean args for upstream forwarding. Closes #322 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
542e7de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c3f8bf60.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-auth-metadata-injection.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 22858711861 --repo smart-mcp-proxy/mcpproxy-go
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
injectAuthMetadata()was mutating theargsmap in-place, causing_auth_*fields (auth_type, agent_name, token_prefix) to be forwarded to upstream MCP servers viaCallTool()validate_callreject unknown keyword arguments, breaking all tool calls for authenticated usersinjectAuthMetadata()now returns a shallow copy; all 3 call sites use separateactivityArgsfor logging and cleanargsfor upstream forwardingTestInjectAuthMetadata_DoesNotMutateOriginalto prevent regressionCloses #322
Test plan
TestInjectAuthMetadata_*/TestGetAuthMetadata_*tests passinternal/...test suite passes (only pre-existing e2e timeout unrelated to change)🤖 Generated with Claude Code