ADK for TypeScript: API Reference
    Preparing search index...

    Class MCPToolset

    A toolset that dynamically discovers and provides tools from a Model Context Protocol (MCP) server.

    This class connects to an MCP server, retrieves the list of available tools, and wraps each of them in an MCPTool instance. This allows the agent to seamlessly use tools from an external MCP-compliant service.

    The toolset can be configured with a filter to selectively expose a subset of the tools provided by the MCP server.

    Usage: import { MCPToolset } from '@google/adk'; import { StreamableHTTPConnectionParamsSchema } from '@google/adk';

    const connectionParams = StreamableHTTPConnectionParamsSchema.parse({ type: "StreamableHTTPConnectionParams", url: "http://localhost:8788/mcp" });

    const mcpToolset = new MCPToolset(connectionParams); const tools = await mcpToolset.getTools();

    Hierarchy (View Summary)

    Constructors

    Properties

    "[BASE_TOOLSET_SIGNATURE_SYMBOL]": true
    prefix?: string
    toolFilter: string[] | ToolPredicate

    Methods

    • Closes the toolset.

      NOTE: This method is invoked, for example, at the end of an agent server's lifecycle or when the toolset is no longer needed. Implementations should ensure that any open connections, files, or other managed resources are properly released to prevent leaks.

      Returns Promise<void>

      A Promise that resolves when the toolset is closed.

    • Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.

      Use cases:

      • Instead of let each tool process the llm request, we can let the toolset process the llm request. e.g. ComputerUseToolset can add computer use tool to the llm request.

      Parameters

      • toolContext: Context

        The context of the tool.

      • llmRequest: LlmRequest

        The outgoing LLM request, mutable this method.

      Returns Promise<void>