fix(a2a): forward passthrough headers on MCP tool invocation path#5020
Open
kimsehwan96 wants to merge 1 commit into
Open
fix(a2a): forward passthrough headers on MCP tool invocation path#5020kimsehwan96 wants to merge 1 commit into
kimsehwan96 wants to merge 1 commit into
Conversation
Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
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.
🔗 Related Issue
Closes #5004
📝 Summary
When an A2A agent is associated with a server, it's auto-registered as an MCP tool and invoked via
POST /servers/{id}/mcp. That path built outbound headers as just{"Content-Type": "application/json"}and never applied the agent's configuredpassthrough_headers, so whitelisted inbound headers (e.g.x-user-id) were silently dropped. The REST path (POST /a2a/{name}→invoke_agent) already honorspassthrough_headers, so the two invocation paths behaved inconsistently.This forwards the agent's whitelisted
passthrough_headersfrom the inbound request on the MCP-tool path too, before the pre-invoke plugin hook — mirroring the existing REST path. Downstream A2A servers that identify the user via headers (e.g. a kagent ADK agent readingx-user-id, otherwise falling back to a randomA2A_USER_<contextId>) now receive them, restoring session/user attribution.🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
x-user-id) reaches the outbound call while a non-whitelisted one (x-secret) is dropped._invoke_a2a_tool/_call_a2a_agenthelpers have the same gap but are currently unreferenced (no live callers), so they're left untouched to keep the change minimal.