Skip to content

Commit c2a6949

Browse files
committed
docs: Document the MCP ToolContext support
Resolves #3209 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
1 parent 9ed7535 commit c2a6949

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-server-boot-starter-docs.adoc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ It automatically converts custom capability handlers registered as Spring beans
146146
Allows servers to expose tools that can be invoked by language models. The MCP Server Boot Starter provides:
147147

148148
* Change notification support
149-
* Tools are automatically converted to sync/async specifications based on server type
149+
* xref:api/tools.adoc[Spring AI Tools] are automatically converted to sync/async specifications based on server type
150150
* Automatic tool specification through Spring beans:
151151

152152
[source,java]
@@ -158,17 +158,6 @@ public ToolCallbackProvider myTools(...) {
158158
}
159159
----
160160

161-
or directly as individual tool callbacks:
162-
163-
[source,java]
164-
----
165-
@Bean
166-
public ToolCallback myTool(...) {
167-
// Create and return a single tool callback
168-
return new ToolCallback(...);
169-
}
170-
----
171-
172161
or using the low-level API:
173162

174163
[source,java]
@@ -187,6 +176,10 @@ The auto-configuration will automatically detect and register all tool callbacks
187176

188177
Tools are de-duplicated by name, with the first occurrence of each tool name being used.
189178

179+
==== Tool Context Support
180+
181+
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(...)`.
182+
190183
=== link:https://spec.modelcontextprotocol.io/specification/2024-11-05/server/resources/[Resource Management]
191184

192185
Provides a standardized way for servers to expose resources to clients.

0 commit comments

Comments
 (0)