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

    Class AgentRegistrySingleMCPToolset

    A specialized BaseToolset subclass designed to represent a single registered MCP server.

    Unlike a standard MCPToolset, this class:

    1. Supports a dynamic headerProvider to fetch/refresh authorization and custom headers immediately before establishing the MCP connection session.
    2. Automatically injects the special gcp.mcp.server.destination.id telemetry metadata identifier into all resolved tools' custom metadata, allowing downstream execute_tool traces to be correctly attributed.

    Hierarchy (View Summary)

    Constructors

    • Parameters

      • options: {
            authCredential?: AuthCredential;
            authScheme?: AuthScheme;
            connectionParams: StreamableHTTPConnectionParams;
            destinationResourceId?: string;
            headerProvider?: (
                context?: ReadonlyContext,
            ) => Record<string, string> | Promise<Record<string, string>>;
            prefix?: string;
            toolFilter?: string[] | ToolPredicate;
        }

        Configuration for the MCP toolset.

        • OptionalauthCredential?: AuthCredential

          Optional credential forwarded to each resolved tool.

        • OptionalauthScheme?: AuthScheme

          Optional auth scheme forwarded to each resolved tool.

        • connectionParams: StreamableHTTPConnectionParams

          HTTP connection parameters for the MCP server.

        • OptionaldestinationResourceId?: string

          Telemetry identifier injected as gcp.mcp.server.destination.id into each resolved tool's custom metadata.

        • OptionalheaderProvider?: (
              context?: ReadonlyContext,
          ) => Record<string, string> | Promise<Record<string, string>>

          Optional async function called immediately before each getTools invocation to supply or refresh request headers (e.g. GCP auth tokens).

        • Optionalprefix?: string

          Optional prefix prepended to each tool name (e.g. myServer_toolName).

        • OptionaltoolFilter?: string[] | ToolPredicate

          Optional predicate or list of tool names to include. When omitted, all tools from the server are returned.

      Returns AgentRegistrySingleMCPToolset

    Properties

    "[BASE_TOOLSET_SIGNATURE_SYMBOL]": true
    authCredential?: AuthCredential
    authScheme?: AuthScheme
    destinationResourceId?: string
    headerProvider?: (
        context?: ReadonlyContext,
    ) => Record<string, string> | Promise<Record<string, string>>
    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>