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
Pass Httpx Auth with token provider to MCPSessionManager #2759
Is your feature request related to a problem? Please describe.
MCPToolset parameter auth_credential takes an access token for the authenticated tool flow. However, our access tokens expire, and I don't see a way to pass a token provider to fetch refreshed tokens automatically.
I did see that the MCPSessionManager has a function _create_client which creates streamablehttp_client and sse_client, depending on the transport mode. These functions accept an auth parameter which is passed internally to the underlying httpx client. But this auth parameter isn't being exposed in the MCPSessionManager nor is it exposed in the top level user interface.
The approach we took was to subclass MCPSessionManager to add a token_provider property on init, and override _create_client, to create our Httpx auth and pass it to the client creation functions. This approach led us to bypass the auth_scheme and auth_credentials mechanisms because, in our estimation, they don't support token refresh mechanisms that the httpx client natively does.
Describe the solution you'd like
I think a preferable solution would be to expose the httpx auth property in the top-level user interface, like MCPToolset, or lower down in MCPTool or MCPSessionManager, so that I can pass an httpx auth object that goes into underlying the httpx MCP client.
Describe alternatives you've considered
An alternative I've considered is to allow us to pass a callable as the auth credential, rather than the token itself, which internally would be called to fetch an updated access token.
Additional context
I'm open to the possibilities that either:
there may already be a token refresh mechanism in ADK for authenticated tools which I just don't know about, or
there is a reason you haven't exposed such a mechanism. Would appreciate your thoughts on the situation.
We are also running on the same issue when using Agent Engine.
Since the MCPToolset object is instantiated when the agent gets pickled, we end up shipping the access token of the CI system to Agent Engine. We have tried to pass a function, but it yields the same result.
Code snippet:
my_mcp=MCPToolset(
connection_params=StreamableHTTPConnectionParams(
url="https://airflow-mcp-staging-gcp-external.naturalint.com/mcp",
auth=get_sa_token()
),
errlog=None
)
root_agent=Agent(
name="test_agent",
model="gemini-2.0-flash",
description="test_agent",
instruction="Make HTTP GET requests to specified URLs and provide agent introduction when requested",
tools=[
my_mcp
]
)
@dannovikov@rei-arifi We have added a custom httpx_client_factory param exposed when creating a McpSessionManager (see #2997) -- I think this should allow you to pass in a httpx auth object. Let me know if it works?
Activity
rei-arifi commentedon Sep 22, 2025
Hello,
We are also running on the same issue when using Agent Engine.
Since the MCPToolset object is instantiated when the agent gets pickled, we end up shipping the access token of the CI system to Agent Engine. We have tried to pass a function, but it yields the same result.
Code snippet:
hangfei commentedon Nov 8, 2025
Please use the main issue to track, closing this for now.
wukath commentedon Jan 14, 2026
@dannovikov @rei-arifi We have added a custom
httpx_client_factoryparam exposed when creating aMcpSessionManager(see #2997) -- I think this should allow you to pass in a httpx auth object. Let me know if it works?dannovikov commentedon Jan 14, 2026
@wukath Ah, cool! Will check it out tomorrow and report back. Thanks for the update