-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
🔴 Required Information
Describe the Bug:
When an MCPToolSet is used as a tool to an Agent. A new mcp-session-id is created for each invocation. This is because the mcp-session-id returned from the MCP initialization is not persisted in the state for reuse.
Steps to Reproduce:
-
Create a test MCP server, which just logs the
mcp-session-idheader for each incoming request/operation. -
Create a new Agent using the above MCP server.
agent = Agent(
model=""
name=""
tools=[
new MCPToolset(
connection_params=StreamableHTTPConnectionParams(
url=url,
timeout=timeout,
)
)
]
)- Run the ADK playground and send messages to the agent, the agent does a
list/toolfor each invocation, also it does not reuse themcp-session-idsent by the server in the previous response.
Expected Behavior:
As per the MCP spec, the MCP server can send an mcp-session-id in the response of initialization request. That mcp-session-id can be used for subsequent requests to maintain stateful servers.
Observed Behavior:
For each turn/invocation, the agent reinitializes the MCP client and creates a new mcp-session-id.
Environment Details:
- ADK Library Version (pip show google-adk): 1.21.0
- Desktop OS:** Mac
- Python Version (python -V): 3.11
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-2.5-flash
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
No
How often has this issue occurred?:
- Always (100%)