Configuration for the MCP toolset.
OptionalauthCredential?: AuthCredentialOptional credential forwarded to each resolved tool.
OptionalauthScheme?: AuthSchemeOptional auth scheme forwarded to each resolved tool.
HTTP connection parameters for the MCP server.
OptionaldestinationResourceId?: stringTelemetry identifier injected as
gcp.mcp.server.destination.id into each resolved tool's custom metadata.
OptionalheaderProvider?: (Optional async function called immediately before each getTools invocation to supply or refresh request headers (e.g. GCP auth tokens).
Optionalprefix?: stringOptional prefix prepended to each tool name (e.g. myServer_toolName).
OptionaltoolFilter?: string[] | ToolPredicateOptional predicate or list of tool names to include. When omitted, all tools from the server are returned.
Readonly[Optional ReadonlyauthOptional ReadonlyauthReadonlyconnectionOptional ReadonlydestinationOptional ReadonlyheaderOptional ReadonlyprefixReadonlytoolCloses 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.
A Promise that resolves when the toolset is closed.
Connects to the underlying MCP server, retrieves tool definitions, prefixes tool names, and injects destination telemetry metadata into each tool.
The headerProvider, if configured, is invoked immediately before the
connection is established so that tokens are always fresh.
Optionalcontext: ReadonlyContextOptional readonly agent context passed to the header provider.
The resolved and optionally filtered list of MCPTool instances.
ProtectedisReturns whether the tool should be exposed to LLM.
The tool to check.
Context used to filter tools available to the agent.
Whether the tool should be exposed to LLM.
Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.
Use cases:
The context of the tool.
The outgoing LLM request, mutable this method.
A specialized BaseToolset subclass designed to represent a single registered MCP server.
Unlike a standard MCPToolset, this class:
headerProviderto fetch/refresh authorization and custom headers immediately before establishing the MCP connection session.gcp.mcp.server.destination.idtelemetry metadata identifier into all resolved tools' custom metadata, allowing downstream execute_tool traces to be correctly attributed.