Class AsyncMcpToolCallback
java.lang.Object
org.springframework.ai.mcp.AsyncMcpToolCallback
- All Implemented Interfaces:
org.springframework.ai.tool.ToolCallback
public class AsyncMcpToolCallback
extends Object
implements org.springframework.ai.tool.ToolCallback
Adapts MCP tools to Spring AI's
ToolCallback interface with asynchronous
execution.
Bridges Model Context Protocol (MCP) tools with Spring AI's tool system, enabling seamless integration of MCP tools in Spring AI applications.
- Author:
- Christian Tzolov, YunKui Lu, Ilayaperumal Gopinathan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructing AsyncMcpToolCallback instances. -
Constructor Summary
ConstructorsConstructorDescriptionAsyncMcpToolCallback(io.modelcontextprotocol.client.McpAsyncClient mcpClient, io.modelcontextprotocol.spec.McpSchema.Tool tool) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic AsyncMcpToolCallback.Builderbuilder()Creates a builder for constructing AsyncMcpToolCallback instances.org.springframework.ai.tool.definition.ToolDefinitionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.tool.ToolCallback
getToolMetadata
-
Constructor Details
-
AsyncMcpToolCallback
@Deprecated public AsyncMcpToolCallback(io.modelcontextprotocol.client.McpAsyncClient mcpClient, io.modelcontextprotocol.spec.McpSchema.Tool tool) Deprecated.useAsyncMcpToolCallback.BuilderinsteadCreates an AsyncMcpToolCallback with default prefixed tool name.- Parameters:
mcpClient- the MCP client for tool executiontool- the MCP tool to adapt
-
-
Method Details
-
getToolDefinition
public org.springframework.ai.tool.definition.ToolDefinition getToolDefinition()- Specified by:
getToolDefinitionin interfaceorg.springframework.ai.tool.ToolCallback
-
getOriginalToolName
-
call
-
call
-
builder
Creates a builder for constructing AsyncMcpToolCallback instances.- Returns:
- a new builder
-
AsyncMcpToolCallback.Builderinstead