-
Notifications
You must be signed in to change notification settings - Fork 3.4k
MCPToolset creates a new mcp-session-id for each invocation #4277
Copy link
Copy link
Closed
Labels
answered[Status] This issue has been answered by the maintainer[Status] This issue has been answered by the maintainermcp[Component] Issues about MCP support[Component] Issues about MCP supportrequest clarification[Status] The maintainer need clarification or more information from the author[Status] The maintainer need clarification or more information from the authortools[Component] This issue is related to tools[Component] This issue is related to tools
Metadata
Metadata
Assignees
Labels
answered[Status] This issue has been answered by the maintainer[Status] This issue has been answered by the maintainermcp[Component] Issues about MCP support[Component] Issues about MCP supportrequest clarification[Status] The maintainer need clarification or more information from the author[Status] The maintainer need clarification or more information from the authortools[Component] This issue is related to tools[Component] This issue is related to tools
🔴 Required Information
Describe the Bug:
When an
MCPToolSetis used as a tool to anAgent. A newmcp-session-idis created for each invocation. This is because themcp-session-idreturned from theMCPinitialization is not persisted in thestatefor 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.
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-idin the response ofinitializationrequest. Thatmcp-session-idcan 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:
Model Information:
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
No
How often has this issue occurred?: