Understanding MCP Tool Routing in OpenSmartRoute
MCP tool routing is a key feature of OpenSmartRoute that enables routing decisions to include tools and resources within a controlled environment. This guide explains how MCP tool routing functions, how to configure it, and best practices for integration.
What is MCP Tool Routing?
MCP (Marketplace Control Protocol) tool routing allows the routing layer to include external tools, resources, and server endpoints as targets within the routing process. This setup enables agents and plans to select and execute tools dynamically, based on policies and available resources.
Setting Up MCP Targets
To enable MCP tool routing, targets must be registered and synchronized with the router. This involves creating a catalogue file that lists available endpoints, tools, and resources. The sync --targets-file command updates this catalogue, which is then loaded during routing commands with the --targets flag.
Synchronizing Targets
sync --targets-file=targets.json
This command updates the catalogue with current endpoints, ensuring the router has the latest state. A scheduled osr marketplace sync maintains daily updates, keeping the router aligned with marketplace state.
Loading Targets
During routing, targets are loaded automatically from the catalogue, and the process restart preserves the state without losing target information.
Connecting External MCP Servers
OpenSmartRoute supports importing external MCP servers as routing targets. This allows tools hosted on other servers to be integrated into the routing pool.
Example: Connecting an MCP Server
from opensmartroute.adapters import connect_mcp, connect_mcp_http
# Connect to a local MCP server
client, targets = connect_mcp(["npx", "-y", "@modelcontextprotocol/server-filesystem", "."], resources=True)
# Connect to a remote MCP server over HTTP
http, remote = connect_mcp_http("https://tools.example.com/mcp", api_key="your_api_key", resources=True)
# Register targets
for t in [*targets, *remote]:
registry.upsert(t)
This setup allows the router to include tools and resources from both local and remote MCP servers.



