Class McpTool
java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.mcp.McpTool
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
ConstructorsConstructorDescriptionMcpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager) Creates a new McpTool with the default ObjectMapper.McpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new McpTool with the default ObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptionOptional<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclarationrepresentation of this tool.io.modelcontextprotocol.client.McpSyncClientrunAsync(Map<String, Object> args, ToolContext toolContext) Calls a tool.com.google.genai.types.SchematoGeminiSchema(io.modelcontextprotocol.spec.McpSchema.JsonSchema openApiSchema) Methods inherited from class com.google.adk.tools.BaseTool
description, longRunning, name, processLlmRequest
-
Constructor Details
-
McpTool
public McpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager) Creates a new McpTool 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.
-
McpTool
public McpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new McpTool 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.objectMapper- The ObjectMapper to use to convert JSON schemas.- Throws:
IllegalArgumentException- If mcpTool or mcpSession are null.
-
-
Method Details
-
getMcpSession
public io.modelcontextprotocol.client.McpSyncClient getMcpSession() -
toGeminiSchema
public com.google.genai.types.Schema toGeminiSchema(io.modelcontextprotocol.spec.McpSchema.JsonSchema openApiSchema) -
declaration
Description copied from class:BaseToolGets theFunctionDeclarationrepresentation of this tool.- Overrides:
declarationin classBaseTool
-
runAsync
-