Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MCPToolset ignores auth_scheme/auth_credential during initialization and tool listing #2168

Copy link
Copy link
@chyok

Description

@chyok
Issue body actions

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.generate()

auth = BearerAuthProvider(
    public_key=key_pair.public_key,
    issuer="https://dev.example.com",
    audience="my-dev-server"
)

token = key_pair.create_token(
    subject="test_user",
    issuer="https://dev.example.com"
)

print("token:", token) # paste the token to next

mcp = FastMCP(name="My MCP Server", auth=auth)

@mcp.tool
def real_time() -> str:
    return "2025-07-24 12:30"

if __name__ == "__main__":
    mcp.run(port=8080)
  1. Use the following ADK client code to access the server:
from google.adk.agents.llm_agent import LlmAgent
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from google.adk.tools.openapi_tool.auth.auth_helpers import token_to_scheme_credential

token = "your paste token"
auth_scheme, auth_credential = token_to_scheme_credential(
    "oauth2Token", "header", "Authorization", token
)

root_agent = LlmAgent(
    model="gemini-2.0-flash",
    name='Assistant',
    instruction="""You are a professional assistant with access to real-time tool.""",
    tools=[
        MCPToolset(
            connection_params=StreamableHTTPServerParams(
                url='https://127.0.0.1:8080/mcp/',
            ),
            auth_scheme=auth_scheme,
            auth_credential=auth_credential
        )
    ],
)
  1. Run agent and ask any question.

  2. See the error due to missing authentication.

Expected behavior

The MCPToolset should correctly apply the auth_scheme and auth_credential during the initialization and tool listing phases, ensuring authentication occurs as expected and the tool can be invoked successfully.

Screenshots

Image

Desktop:

  • OS: Mac OS
  • Python version: python 3.11.9
  • ADK version: v1.8.0

Model Information:

Model: gemini-2.0-flash

Additional context

Reactions are currently unavailable

Metadata

Metadata

Labels

mcp[Component] Issues about MCP support[Component] Issues about MCP supporttools[Component] This issue is related to tools[Component] This issue is related to tools

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.