home / mcp / mcp local router mcp server
Aggregates multiple MCP servers behind a single interface, enabling SSE and stdio transports for unified tool access.
Configuration
View docs{
"mcpServers": {
"kaichen-mcp-local-router": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop"
],
"env": {
"LINEAR_ACCESS_TOKEN": "your_personal_access_token"
}
}
}
}You set up a local MCP router that aggregates multiple upstream MCP servers behind a single interface. It lets you work with several MCP sources through one entry point, streams tool surfaces via SSE, and routes messages through a unified channel for downstream clients.
You run the router with a configuration that defines the upstream MCP servers you want to connect to. Then you choose a transport method to expose the combined surface to clients. SSE lets you stream tool surfaces from all configured servers, or from a single server, through endpoints you access in your browser or client.
Common usage patterns involve starting the router in one of two modes: streaming with SSE or using stdio transport for programmatic control. With SSE, you access two kinds of endpoints: the aggregated surface at /sse and per-upstream surfaces at /sse/{serverName}. The serverName must match the key you provide for each upstream in the configuration file, and path segments must be URL-safe.
To organize your environment, create a configuration file that lists your upstream MCP servers. You then run the router with that config and select your preferred transport. All SSE connections share the same POST channel at POST /message?sessionId=….
You can also run the router using stdio transport, which communicates over standard I/O. This is useful for embedding the router in other processes or for scripting. When you choose stdio, the router reads its configuration from your file and exposes the configured upstreams through the chosen transport.
Prerequisites: you need a Rust toolchain compatible with 2021 Edition and a working development environment for compiling Rust projects.
# Build the project
cargo build --release
# Run the router with your configuration and stdio transport
cargo run --release -- --config mcp-config.json --transport stdioThe configuration file defines multiple upstream MCP servers. Each server configuration includes a command to run, arguments, and optional environment variables to inject into the process. The keys under mcpServers become the server names and also determine the path segments for per-upstream endpoints when using SSE.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop"
],
"env": {
"LINEAR_ACCESS_TOKEN": "your_personal_access_token"
}
},
"workspace-search": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-everything"
],
"env": {}
}
}
}- Ensure server names in the configuration are URL-safe since they appear in path segments for per-upstream endpoints.
- If you inject environment variables, keep sensitive values secure and consider using a secret management workflow for production deployments.
Expose aggregated and per-upstream streams at /sse and /sse/{serverName} to provide real-time tool surfaces from configured MCP servers.
Run upstream MCP servers via standard I/O transport, injecting environment variables as configured.
Aggregate tool surfaces from multiple upstream MCP servers into a single interface for downstream clients.