Package org.springframework.ai.mcp
Class SyncMcpToolCallback
java.lang.Object
org.springframework.ai.mcp.SyncMcpToolCallback
- All Implemented Interfaces:
ToolCallback
Synchronous adapter bridging MCP tools to Spring AI's
ToolCallback
interface.
Handles tool execution and data conversion between MCP and Spring AI.- Since:
- 1.0.0
- Author:
- Christian Tzolov, YunKui Lu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder forSyncMcpToolCallback
instances. -
Constructor Summary
ConstructorsConstructorDescriptionSyncMcpToolCallback
(io.modelcontextprotocol.client.McpSyncClient mcpClient, io.modelcontextprotocol.spec.McpSchema.Tool tool) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic SyncMcpToolCallback.Builder
builder()
Creates a builder for constructingSyncMcpToolCallback
instances.Execute tool with the given input and return the result to send back to the AI model.call
(String toolCallInput, ToolContext toolContext) Execute tool with the given input and context, and return the result to send back to the AI model.Returns the original MCP tool name without prefixing.Definition used by the AI model to determine when and how to call the tool.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.tool.ToolCallback
getToolMetadata
-
Constructor Details
-
SyncMcpToolCallback
@Deprecated public SyncMcpToolCallback(io.modelcontextprotocol.client.McpSyncClient mcpClient, io.modelcontextprotocol.spec.McpSchema.Tool tool) Deprecated.usebuilder()
insteadCreates a callback with default settings.- Parameters:
mcpClient
- the MCP client for tool executiontool
- the MCP tool to adapt
-
-
Method Details
-
getToolDefinition
Description copied from interface:ToolCallback
Definition used by the AI model to determine when and how to call the tool.- Specified by:
getToolDefinition
in interfaceToolCallback
-
getOriginalToolName
Returns the original MCP tool name without prefixing.- Returns:
- the original tool name
-
call
Description copied from interface:ToolCallback
Execute tool with the given input and return the result to send back to the AI model.- Specified by:
call
in interfaceToolCallback
-
call
Description copied from interface:ToolCallback
Execute tool with the given input and context, and return the result to send back to the AI model.- Specified by:
call
in interfaceToolCallback
-
builder
Creates a builder for constructingSyncMcpToolCallback
instances.- Returns:
- a new builder
-
builder()
instead