A virtual MCP server that aggregates tools from multiple downstream MCP servers into a unified interface. Supports hot-swapping and skill negotiation.
clientsList of connected MCP clients.
tool_mapMapping of tool names to their source clients.
capabilitiesAggregated capabilities from all clients.
new()Create a new MCP Router.
McpRouter$new()A new McpRouter object.
add_client()Add an MCP client to the router.
McpRouter$add_client(name, client)nameUnique name for this client.
clientAn McpClient object.
Self (invisibly).
connect()Connect to an MCP server and add it to the router.
McpRouter$connect(name, command, args = character(), env = NULL)nameUnique name for this connection.
commandCommand to run the MCP server.
argsCommand arguments.
envEnvironment variables.
Self (invisibly).
remove_client()Remove an MCP client from the router (hot-swap out).
McpRouter$remove_client(name)nameName of the client to remove.
Self (invisibly).
list_tools()List all available tools across all connected clients.
McpRouter$list_tools()A list of tool definitions.
call_tool()Call a tool, routing to the appropriate client.
McpRouter$call_tool(name, arguments = list())nameTool name.
argumentsTool arguments.
The tool result.
as_sdk_tools()Get all tools as SDK Tool objects for use with generate_text.
McpRouter$as_sdk_tools()A list of Tool objects.
negotiate()Negotiate capabilities with a specific client.
McpRouter$negotiate(client_name)client_nameName of the client.
A list of negotiated capabilities.
status()Get router status.
McpRouter$status()A list with status information.
clone()The objects of this class are cloneable with this method.
McpRouter$clone(deep = FALSE)deepWhether to make a deep clone.