Gopal S Akshintala
06/04/2025, 6:00 AMVadim Briliantov
06/04/2025, 11:20 AMGopal S Akshintala
06/04/2025, 11:30 AMGopal S Akshintala
06/04/2025, 11:38 AMVadim Briliantov
06/04/2025, 11:41 AMOlga Galchenko
06/04/2025, 11:44 AMOlga Galchenko
06/04/2025, 11:49 AMGopal S Akshintala
06/05/2025, 11:32 AMVadim Briliantov
06/05/2025, 11:35 AMGopal S Akshintala
06/05/2025, 11:40 AMVadim Briliantov
06/05/2025, 11:59 AMval myTools = McpToolRegistryProvider.fromTransport(...) + ToolRegistry {
tool(ExtraTool1)
tool(ExtraTool2)
} + McpToolRegistryProvider.fromTransport(...some other MCP server...)
And then you provide it as a normal ToolRegistry to any agent, and then you can limit tools in subgraphs as the following:
val mySubgraph by subgraph(tools = listOf(...)) {
// only provided tools will be available to LLM inside this subgraph
// Note: of course, as subgraphs share the same history and context, some older subgraphs could populate different tool cals in the history, that are not available here to the LLM. This might be confusing to the model or even break the model, and that's why we have `MissingToolsConversionStrategy` in AIAgentConfig, which defaults to `MissingToolsConversionStrategy.Missing(ToolCallDescriber.JSON)` i.e. missing tools in the history will be described as JSON plain text and all tool calls will be substituted to user messages with plain text before sending to the actual LLM. So, this problem won't be hitting you, but you may also want to play different strategies of describing tools. JFYI.
...
}
And also to get the tools from the MCP tool registry (or any tool registry in general), you can use toolRegistry.tools
that would give you a list of tools.
So, for example if different MCP tools are needed for different subgraphs, you can do something like this:
val mcpToolRegistry1 = McpToolRegistryProvider.fromTransport(...)
val mcpToolRegistry1 = McpToolRegistryProvider.fromTransport(...some other MCP server...)
val allTools = mcpTools1 + mcpTools2 + ...
val strategy = strategy("yours") {
val firstPart by subgraph(tools = mcpToolRegistry1.tools) { ... }
val secondPart by subgraph(tools = mcpToolRegistry2.tools) { ... }
val commonPary by subgraph { ... } // all tools available
// some edges
...
}
val agent = AIAgent(toolRegistry = allTools, strategy = strategy, ...)
Vadim Briliantov
06/06/2025, 10:48 AMGopal S Akshintala
06/06/2025, 6:46 PM