McpToolset
Connects to an MCP Server and exposes the server's MCP tools to an agent as ADK BaseTools.
McpToolset manages the lifecycle of the connection to a single MCP server and lazily fetches the server's tool list on first use. The instance can then be passed directly to an LlmAgent's toolsets.
Instances are created via McpToolset.McpToolsetConfig.toToolset, for example:
val toolset =
McpToolset.McpToolsetConfig(
stdioConnectionParams =
McpConnectionParameters.Stdio(
serverParameters =
ServerParameters.builder("npx")
.args("-y", "@modelcontextprotocol/server-filesystem")
.build()
),
toolFilter = ToolFilter.allowList("read_file", "list_directory"),
)
.toToolset()The constructor is internal; user code should use McpToolset.McpToolsetConfig.toToolset instead. Portable Streamable HTTP on JVM and Android uses RemoteMcpToolsetConfig.
A configured headerProvider is invoked before tool discovery and again before each tool call (matching ADK Python). An IllegalArgumentException from that provider or from a ToolFilter.Predicate during getTools is wrapped in McpToolLoadingException.
Types
Configuration for an McpToolset, used to construct one via toToolset.