docs: Document the MCP ToolContext support
Resolves #3209 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
committed by
Christian Tzolov
parent
9ed7535ba0
commit
c2a694900c
@@ -146,7 +146,7 @@ It automatically converts custom capability handlers registered as Spring beans
|
||||
Allows servers to expose tools that can be invoked by language models. The MCP Server Boot Starter provides:
|
||||
|
||||
* Change notification support
|
||||
* Tools are automatically converted to sync/async specifications based on server type
|
||||
* xref:api/tools.adoc[Spring AI Tools] are automatically converted to sync/async specifications based on server type
|
||||
* Automatic tool specification through Spring beans:
|
||||
|
||||
[source,java]
|
||||
@@ -158,17 +158,6 @@ public ToolCallbackProvider myTools(...) {
|
||||
}
|
||||
----
|
||||
|
||||
or directly as individual tool callbacks:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public ToolCallback myTool(...) {
|
||||
// Create and return a single tool callback
|
||||
return new ToolCallback(...);
|
||||
}
|
||||
----
|
||||
|
||||
or using the low-level API:
|
||||
|
||||
[source,java]
|
||||
@@ -187,6 +176,10 @@ The auto-configuration will automatically detect and register all tool callbacks
|
||||
|
||||
Tools are de-duplicated by name, with the first occurrence of each tool name being used.
|
||||
|
||||
==== Tool Context Support
|
||||
|
||||
The xref:api/tools.adoc#_tool_context[ToolContext] is supported, allowing contextual information to be passed to tool calls. It contains an `McpSyncServerExchange` instance under the `exchange` key, accessible via `McpToolUtils.getMcpExchange(toolContext)`. See this https://github.com/spring-projects/spring-ai-examples/blob/3fab8483b8deddc241b1e16b8b049616604b7767/model-context-protocol/sampling/mcp-weather-webmvc-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java#L59-L126[example] demonstrating `exchange.loggingNotification(...)` and `exchange.createMessage(...)`.
|
||||
|
||||
=== link:https://spec.modelcontextprotocol.io/specification/2024-11-05/server/resources/[Resource Management]
|
||||
|
||||
Provides a standardized way for servers to expose resources to clients.
|
||||
|
||||
Reference in New Issue
Block a user