Class McpAsyncTool
java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.mcp.AbstractMcpTool<io.modelcontextprotocol.client.McpAsyncClient>
com.google.adk.tools.mcp.McpAsyncTool
public final class McpAsyncTool
extends AbstractMcpTool<io.modelcontextprotocol.client.McpAsyncClient>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class BaseTool
BaseTool.ToolArgsConfig, BaseTool.ToolConfigModifier and TypeClassDescriptionstatic classConfiguration class for tool arguments that allows arbitrary key-value pairs.static classConfiguration class for a tool definition in YAML/JSON. -
Field Summary
Fields inherited from class AbstractMcpTool
mcpSession, mcpSessionManager, mcpTool, objectMapperModifier and TypeFieldDescriptionprotected io.modelcontextprotocol.client.McpAsyncClientprotected final McpSessionManagerprotected final io.modelcontextprotocol.spec.McpSchema.Toolprotected final com.fasterxml.jackson.databind.ObjectMapper -
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
Methods inherited from class AbstractMcpTool
annotations, declaration, getMcpSession, meta, wrapCallResultModifier and TypeMethodDescriptionio.modelcontextprotocol.spec.McpSchema.ToolAnnotationsOptional<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclarationrepresentation of this tool.io.modelcontextprotocol.client.McpAsyncClientmeta()wrapCallResult(com.fasterxml.jackson.databind.ObjectMapper objectMapper, String mcpToolName, io.modelcontextprotocol.spec.McpSchema.CallToolResult callResult) Methods inherited from class BaseTool
customMetadata, description, fromConfig, longRunning, name, processLlmRequest, runAsync, runAsync, runAsync, runAsync, runAsync, runAsync, setCustomMetadataModifier and TypeMethodDescriptionReturns a read-only view of the tool metadata.static BaseToolfromConfig(BaseTool.ToolConfig config, String configAbsPath) Creates a tool instance from a config.booleanname()io.reactivex.rxjava3.core.CompletableprocessLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext) Processes the outgoingLlmRequest.Builder.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.core.type.TypeReference<? extends O> typeReference) Calls a tool with generic arguments, returning the results converted to a specified type reference.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.core.type.TypeReference<? extends O> typeReference) Calls a tool with generic arguments and a customObjectMapper, returning the results converted to a specified type reference.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Class<? extends O> oClass) Calls a tool with generic arguments and a customObjectMapper, returning the results converted to a specified class.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, Class<? extends O> oClass) Calls a tool with generic arguments, returning the results converted to a specified class.runAsync(T args, ToolContext toolContext) Calls a tool with generic arguments and returns a map of results.runAsync(T args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Calls a tool with generic arguments using a customObjectMapperand returns a map of results.voidsetCustomMetadata(String key, Object value) Sets custom metadata to the tool associated with a key.
-
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
-
runAsync
-