pi-mcp-router
Path-scoped, multi-account MCP routing for Pi
Package details
Install pi-mcp-router from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-mcp-router- Package
pi-mcp-router- Version
1.0.0- Published
- Jul 15, 2026
- Downloads
- 148/mo · 148/wk
- Author
- r0r-5chach
- License
- MIT
- Types
- extension
- Size
- 22.1 KB
- Dependencies
- 1 dependency · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
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.