Class McpAsyncTool
java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.mcp.McpAsyncTool
Initializes a MCP tool.
This wraps a MCP Tool interface and an active MCP Session. It invokes the MCP Tool through executing the tool from remote MCP Session.
-
Constructor Summary
ConstructorsConstructorDescriptionMcpAsyncTool
(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpAsyncClient mcpSession, McpSessionManager mcpSessionManager) Creates a new McpAsyncTool with the default ObjectMapper.McpAsyncTool
(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpAsyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new McpAsyncTool -
Method Summary
Modifier and TypeMethodDescriptionOptional
<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclaration
representation of this tool.io.modelcontextprotocol.client.McpAsyncClient
runAsync
(Map<String, Object> args, ToolContext toolContext) Calls a tool.com.google.genai.types.Schema
toGeminiSchema
(io.modelcontextprotocol.spec.McpSchema.JsonSchema openApiSchema) Methods inherited from class com.google.adk.tools.BaseTool
description, longRunning, name, processLlmRequest
-
Constructor Details
-
McpAsyncTool
public McpAsyncTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpAsyncClient mcpSession, McpSessionManager mcpSessionManager) Creates a new McpAsyncTool with the default ObjectMapper.- Parameters:
mcpTool
- The MCP tool to wrap.mcpSession
- The MCP session to use to call the tool.mcpSessionManager
- The MCP session manager to use to create new sessions.- Throws:
IllegalArgumentException
- If mcpTool or mcpSession are null.
-
McpAsyncTool
public McpAsyncTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpAsyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new McpAsyncTool- Parameters:
mcpTool
- The MCP tool to wrap.mcpSession
- The MCP session to use to call the tool.mcpSessionManager
- The MCP session manager to use to create new sessions.objectMapper
- The ObjectMapper to use to convert JSON schemas.- Throws:
IllegalArgumentException
- If mcpTool or mcpSession are null.
-
-
Method Details
-
getMcpSession
public io.modelcontextprotocol.client.McpAsyncClient getMcpSession() -
toGeminiSchema
public com.google.genai.types.Schema toGeminiSchema(io.modelcontextprotocol.spec.McpSchema.JsonSchema openApiSchema) -
declaration
Description copied from class:BaseTool
Gets theFunctionDeclaration
representation of this tool.- Overrides:
declaration
in classBaseTool
-
runAsync
-