pi-mcp-router
extensionPath-scoped, multi-account MCP routing for Pi
by — · v1.0.0 · published 3w ago
$ pi install npm:pi-mcp-routerSignals
Download trend
189 downloads · last 12 weeks (weekly)
README
Pi MCP Router
Path-scoped, multi-account routing for pi-mcp-adapter 2.11.0. Servers are exposed as account__server; matching parent and nested rules are additive.
Install
Install permanently:
pi install npm:pi-mcp-router
Or try it temporarily:
pi -e npm:pi-mcp-router
Do not also install/load pi-mcp-adapter as a Pi package: that would initialize an unfiltered second copy. postinstall applies and verifies a narrow version-guarded isolation patch to the pinned adapter.
Create ~/.pi/mcp-router.json (override with PI_MCP_ROUTER_CONFIG):
{
"version": 1,
"accounts": { "work": { "servers": { "github": { "url": "https://example.test/mcp" } } } },
"access": [{ "path": "/absolute/project", "accounts": ["work"] }],
"settings": { "defaultServers": ["github"] }
}
Rules use canonical real paths, so symlinks cannot escape or duplicate scopes. Paths must exist. Runtime files are mode 0600 under ~/.pi/mcp-router-runtime; account remote state is separated with MCP_REMOTE_CONFIG_DIR. Config updates use an exclusive lock, atomic rename, and .bak backup.
/mcp-route supports add [account server url] (interactive when omitted), list, show [account], allow <path> <account>, disallow, remove <account> <server>, account remove <account>, test [path], reload, and edit. allow/disallow expand ~ and environment variables and store the existing path's canonical absolute form. Manually edited access roots must already be absolute and canonical. Changes require restart; reload reports this explicitly.
Security
No matching route means the adapter is not initialized. Routed startup fails closed if config validation or the adapter isolation guard fails. URLs and secret-like fields are redacted by show. An explicit user --mcp-config intentionally bypasses routing. The --mcp-config=path spelling is normalized to the adapter-supported --mcp-config path form; its normal merge behavior then applies and a warning is printed.