✨ Feature: Pass user context to MCP tools and A2A agents for tool-side authorization - #3798
Open
EDDIWARD wants to merge 3 commits into
Open
✨ Feature: Pass user context to MCP tools and A2A agents for tool-side authorization#3798EDDIWARD wants to merge 3 commits into
EDDIWARD wants to merge 3 commits into
Conversation
EDDIWARD
requested review from
Dallas98,
WMC001 and
jeffwu-1999
as code owners
August 28, 2026 00:40
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Pass the caller's user information (tenant name, user name/account, user groups) through to MCP tools and external A2A agents according to each tool's declaration, so tools can authorize on their own before accessing data. The platform performs no authorization itself — it only forwards the authenticated session identity.
inputSchemadeclares any oftenant_id / tenant_name / user_id / user_name / user_account / user_groups, the platform injects the current caller's values at call time. Undeclared fields are never injected and existing tool parameters stay untouched.metadata.user_context.agent-development/agent-configuration: "Pass User Information to Tools (Tool-side Authorization)" / 「向工具透传用户信息(工具侧鉴权)」).Before / After (payload-level comparison, no UI involved)
MCP tool call — example tool
query_sales_datadeclaresuser_accountanduser_groupsin its inputSchema for data authorization:Before — the conventional fields are visible to the model, and whatever arguments the model generates reach the MCP server as-is (a tool needing caller identity gets none):
After — the conventional fields are hidden from the model; the platform wraps the tool and appends the session-resolved values right before execution:
External A2A agent request metadata:
Before:
payload.metadata = {}After:
Why
Tools that access tenant/user-scoped data previously had no reliable way to know who is calling — they could only use static, tenant-level credentials configured on the MCP connection. With this change, tools can enforce their own per-user/per-group data authorization using identity that is guaranteed to come from the authenticated session (never from model output), while the platform stays out of the authorization decision itself.
Validation
test_tool_user_context.py,TestBuildToolUserContext,TestAgentTreeNeedsUserContext,TestResolveToolUserContext, A2A wrapper metadata tests).user_contextkwarg (test_run_agent.py,test_create_agent_info.py); full files re-run locally with no regressions.