Class McpTool

java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.mcp.McpTool

public final class McpTool extends BaseTool
"""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 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

      public Optional<com.google.genai.types.FunctionDeclaration> declaration()
      Description copied from class: BaseTool
      Gets the FunctionDeclaration representation of this tool.
      Overrides:
      declaration in class BaseTool
    • runAsync

      public io.reactivex.rxjava3.core.Single<Map<String,Object>> runAsync(Map<String,Object> args, ToolContext toolContext)
      Description copied from class: BaseTool
      Calls a tool.
      Overrides:
      runAsync in class BaseTool