AgentConfig - auth passthrough between agents. #2743
Replies: 2 comments
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Yes, it is possible to pass authentication tokens from a Hi @johnkrzywanek, Thanks for your question. What you're describing is a common and supported pattern in ADK. Here’s a more detailed explanation of how you can achieve this: Authentication in ADKThe ADK framework has a robust system for handling authentication. The two key components you'll be working with are Passing Authentication to MCP ToolsThe Here is a conceptual example: from google.adk.tools.auth_schemes import Oauth2
from google.adk.tools.credentials import UserCredential
from google.adk.tools.mcp_tool import MCPToolset
# Define the OAuth 2.0 scheme for your MCP server
# The authorization_url and token_url would be for your upstream API
oauth_scheme = Oauth2(
authorization_url="https://your-auth-server.com/auth",
token_url="https://your-auth-server.com/token",
scopes=["your:scope"],
)
# Use UserCredential to indicate that the tool should use the user's identity
# The ADK will handle the flow of obtaining the token from the user
user_credential = UserCredential()
# Initialize your MCPToolset with the auth configuration
mcp_toolset = MCPToolset(
# ... other parameters
auth_scheme=oauth_scheme,
auth_credential=user_credential,
)
# Your sub-agent would then use this toolset Agent-to-Agent (A2A) AuthenticationFor a concrete example of how to handle authentication between agents, I highly recommend you look at the A2A OAuth Authentication Sample Agent. You can find it here: A2A Auth Sample README. This sample demonstrates how a remote agent can surface an OAuth authentication request to a local agent, which then handles the user-interactive login flow. This is very similar to your scenario where the Putting It All TogetherIn your setup:
For more details on MCP tools, you can refer to the MCP Tools Documentation. I hope this helps you get started! Let us know if you have any more questions. References: |
Beta Was this translation helpful? Give feedback.
-
Sorry, it seems you did not get my question right, I'm asking about if it's possible in the codeless, YAML Agent Config part of the SDK, not the Python code. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, hope that it's the right place to ask questions about this, but it's not clear from the Agent Config docs.
My goal is to have a
root_agent
and a fewsub_agents
, where those sub_agents will be connected to MCP servers ( ideally via ADK's includedMCPToolkit
).An external client will send a prompt to the
root_agent
along with theAuthorization: Bearer token
in a header. I'd like for this auth token to be passed to sub_agents and then also passed through to the MCP server, which will use it to authorize to an upstream API.Is something like this possible with the current Agent Config implementation? If so, how exactly should I configure this?
Beta Was this translation helpful? Give feedback.
All reactions