When calling the mcp server, I hope to pass the toolContext,What should I do in this situation?
Comment From: msievers
That is a really important point, and I’ve just stumbled over it myself. In my opinion, it’s essential for serious use, even if it’s just about including a tenant ID, a user ID, or something similar, so that the tool knows in which tenant it should search for certain information, or for which user, etc.
Comment From: msievers
When I look at the MCP protocol specification, something like the SpringAI ToolContext
is not directly supported in the MCP tools/call
.
https://modelcontextprotocol.io/specification/2025-06-18/schema#tools%2Fcall
In theory, you could add such additional data into the _meta
field of the tools/call
request.
https://modelcontextprotocol.io/specification/2025-06-18/basic#meta
This could be subsequently handled in a generic way by the mcp server, for instance, everything placed in the _meta
field of the MCP tools/call
would subsequently appear in the ToolContext
.