Class McpTool
java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.mcp.McpTool
"""Initializes a MCPTool.
This tool wraps a MCP Tool interface and an active MCP Session. It invokes the MCP Tool through executing the tool from remote MCP Session.
Example: tool = MCPTool(mcp_tool=mcp_tool, mcp_session=mcp_session)
Args: mcp_tool: The MCP tool to wrap. mcp_session: The MCP session to use to call the tool. auth_scheme: The authentication scheme to use. auth_credential: The authentication credential to use.
Raises: ValueError: If mcp_tool or mcp_session is None.
-
Constructor Summary
ConstructorsConstructorDescriptionMcpTool
(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager) McpTool
(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionOptional
<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclaration
representation of this tool.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
-
McpTool
public McpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager) -
McpTool
public McpTool(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.client.McpSyncClient mcpSession, McpSessionManager mcpSessionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
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
-