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

    Class MCPTool

    Represents a tool exposed via the Model Context Protocol (MCP).

    This class acts as a wrapper around a tool definition received from an MCP server. It translates the MCP tool's schema into a format compatible with the Gemini AI platform (FunctionDeclaration) and handles the remote execution of the tool by communicating with the MCP server through an MCPSessionManager.

    When an LLM decides to call this tool, the runAsync method will be invoked, which in turn establishes an MCP session, sends a callTool request with the provided arguments, and returns the result from the remote tool.

    Hierarchy (View Summary)

    Constructors

    Properties

    description: string
    isLongRunning: boolean
    name: string

    Accessors

    • get apiVariant(): GoogleLLMVariant

      The Google API LLM variant to use.

      Returns GoogleLLMVariant

    Methods

    • Gets the OpenAPI specification of this tool in the form of a FunctionDeclaration.

      NOTE

      • Required if subclass uses the default implementation of processLlmRequest to add function declaration to LLM request.
      • Otherwise, can be skipped, e.g. for a built-in GoogleSearch tool for Gemini.

      Returns FunctionDeclaration

      The FunctionDeclaration of this tool, or undefined if it doesn't need to be added to LlmRequest.config.

    • Runs the tool with the given arguments and context.

      NOTE

      • Required if this tool needs to run at the client side.
      • Otherwise, can be skipped, e.g. for a built-in GoogleSearch tool for Gemini.

      Parameters

      Returns Promise<unknown>

      A promise that resolves to the tool response.