Skip to content
← Back to activity

Immutable solution version

MCPToolset ignores auth_scheme/auth_credential during initialization and tool listing

Version 1Sign in to save

Complete solution

How to mCPToolset ignores auth_scheme/auth_credential during initialization and tool listing. Verified in gh:google/adk-python#2168.

What this teaches

How to mCPToolset ignores authscheme/authcredential during initialization and tool listing.

The problem

Issue google/adk-python#2168 (closed, 24 comments): Describe the bug When passing auth_scheme and auth_credential to MCPToolset, the authentication is not performed during the MCP initialization and tool listing phases. This results in a failure when using authenticated MCP services. To Reproduce Steps to reproduce the behavior: 1.Install the MCP server: `` pip install fastmcp 2.Run the following MCP server code: `` from fastmcp import FastMCP from fastmcp.server.auth import BearerAuthProvider from fastmcp.server.auth.providers.bearer import RSAKeyPair key_pair = RSAKeyPair.

What worked (verified answer)

MCPToolset wasn't sending auth during MCP initialization and tool listing: authscheme and authcredential were only wired into individual tool calls, so the Bearer token never went out during tools/list and authenticated MCP servers returned 401. Fixed in ADK v1.24.0. If you can't upgrade yet, the workaround is adding headerprovider=lambda ctx: {'Authorization': f'Bearer {yourtoken}'} to the McpToolset constructor, which injects the auth header directly into the session.

Source

gh:google/adk-python#2168 - https://github.com/google/adk-python/issues/2168

Evidence

In gh:google/adk-python#2168, the reporter ran into: Issue google/adk-python#2168 (closed, 24 comments): Describe the bug When passing auth_scheme and auth_credential to MCPToolset, the authentication is not performed during the MCP initialization and tool listing phases. This results in a failure when using authenticated MCP services. To Reproduce Steps to reproduce the behavior: 1.Install the MCP server: `` pip install fastmcp 2.Run the following MCP server code: `` from fastmcp import FastMCP from fastmcp.server.auth import BearerAuthProvider from fastmcp.server.auth.providers.bearer import RSAKeyPair keypair =... The verified answer was: MCPToolset wasn't sending auth during MCP initialization and tool listing: authscheme and authcredential were only wired into individual tool calls, so the Bearer token never went out during tools/list and authenticated MCP servers returned 401. Fixed in ADK v1.24.0. If you can't upgrade yet, the workaround is adding headerprovider=lambda ctx: {'Authorization': f'Bearer {your_token}'} to the McpToolset constructor, which injects the auth header directly into the session. Source issue: https://github.com/google/adk-python/issues/2168

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_xWPNYKNrAKWeCDUVdZo5uA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">MCPToolset ignores auth_scheme/auth_credential during initialization and tool listing <span>— Vectle</span></a>