# 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)

- BaseTool
  - MCPTool

- Defined in tools/mcp/mcp_tool.ts:33

## Constructors

### constructor

- new MCPTool(mcpTool: {}, mcpSessionManager: MCPSessionManager): MCPTool

  #### Parameters

  - mcpTool: {}
  - mcpSessionManager: MCPSessionManager

  #### Returns MCPTool

  Overrides BaseTool.constructor

  - Defined in tools/mcp/mcp_tool.ts:37

## Properties

### `Readonly`[BASE_TOOL_SIGNATURE_SYMBOL]

"[BASE_TOOL_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK base tool class.

Inherited from BaseTool.[BASE_TOOL_SIGNATURE_SYMBOL]

- Defined in tools/base_tool.ts:64

### `Readonly` description

description: string

Inherited from BaseTool.description

- Defined in tools/base_tool.ts:67

### `Readonly` isLongRunning

isLongRunning: boolean

Inherited from BaseTool.isLongRunning

- Defined in tools/base_tool.ts:68

### `Readonly` name

name: string

Inherited from BaseTool.name

- Defined in tools/base_tool.ts:66

## Accessors

### apiVariant

- get apiVariant(): GoogleLLMVariant

  The Google API LLM variant to use.

  #### Returns GoogleLLMVariant

  Inherited from BaseTool.apiVariant

  - Defined in tools/base_tool.ts:151

## Methods

### _getDeclaration

- _getDeclaration(): FunctionDeclaration

  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.

  Overrides BaseTool._getDeclaration

  - Defined in tools/mcp/mcp_tool.ts:43

### processLlmRequest

- processLlmRequest(request: ToolProcessLlmRequest): Promise<void>

  Processes the outgoing LLM request for this tool.

  Use cases:

  - Most common use case is adding this tool to the LLM request.
  - Some tools may just preprocess the LLM request before it's sent out.

  #### Parameters

  - request: ToolProcessLlmRequest

    The request to process the LLM request.

  #### Returns Promise<void>

  Inherited from BaseTool.processLlmRequest

  - Defined in tools/base_tool.ts:120

### runAsync

- runAsync(request: RunAsyncToolRequest): Promise<unknown>

  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

  - request: RunAsyncToolRequest

    The request to run the tool.

  #### Returns Promise<unknown>

  A promise that resolves to the tool response.

  Overrides BaseTool.runAsync

  - Defined in tools/mcp/mcp_tool.ts:54