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.
Comment From: msievers
I just realized that this _meta field has just recently appeared in the MCP specification and, accordingly, has not yet been implemented in the MCP Java SDK. We'd probably need to wait for that to be available in the SDK before it can be properly used in SpringAI.
MR which adds _meta to the MCP schema(s)
* https://github.com/modelcontextprotocol/modelcontextprotocol/pull/710
MR which adds support for _meta field in MCP Java SDK
* https://github.com/modelcontextprotocol/java-sdk/pull/368