nicobailon/pi-mcp-adapter
Token-efficient MCP adapter for Pi coding agent
1,171 ★240 forksTypeScriptUpdated 1d ago
What you need to know
An MCP adapter extension for the Pi agent (badlogic/pi-mono) that exposes all configured MCP servers through a single proxy tool (~200 tokens) instead of hundreds of tool definitions, keeping servers lazy so they only start when a tool is actually called.
Install
pi install npm:pi-mcp-adapter pi install npm:glimpseui (optional, for native macOS MCP UI rendering)
Usage
- •Reads standard MCP files automatically: .mcp.json, ~/.config/mcp/mcp.json, ~/.agents/mcp.json, ~/.agents/mcp/mcp.json; or run `/mcp setup` / `pi-mcp-adapter init` to adopt host-specific configs (Cursor, Claude Code, Codex, etc.) or scaffold a minimal .mcp.json
- •Call tools via the proxy: mcp({ search: "screenshot" }), mcp({ tool: "chrome_devtools_take_screenshot", args: { format: "png" } })
- •Run /mcp for an interactive panel, /mcp setup for guided first-run setup, /mcp reconnect <server> to refresh a server, /mcp-auth <server> for OAuth
- •For multi-call work, write plain JavaScript and run it with the default-on mcpScript tool (search/describe/call/loop/chain)
Key features
- ✓One ~200-token `mcp` proxy tool instead of dozens of tool definitions; servers are lazy by default and disconnect after an idle timeout (default 10 min)
- ✓Tool metadata cached to disk, so search/list/describe work without live connections
- ✓directTools option registers individual tools as first-class Pi tools; includeTools/excludeTools filtering; ~150-300 tokens per direct tool
- ✓Lifecycle modes: lazy, eager, keep-alive, lazy-keep-alive; idempotent health-check auto-reconnect
- ✓OAuth (authorization_code / client_credentials), bearer auth, approval gates (approveTools), output guard, MCP prompts as slash commands, MCP UI integration, Agent Plugins 1.0 package loading, rmcp-mux shared stdio processes
Best for
Using MCP servers inside the Pi agent without burning the context window on verbose tool definitions.
Caveats
- ⚠Cross-session server sharing not yet implemented (each Pi session runs its own server processes)
- ⚠MCP sampling support is text-only; context inclusion, tools, stop sequences, audio, and image content are rejected
- ⚠Compact MCP result rendering summarizes text; images are controlled by Pi's image display settings
- ⚠Package ships TypeScript source - requires a TypeScript-capable loader (e.g. node --import tsx) for standalone Node import
- ⚠Persistent OAuth on headless Linux requires an unlocked keyring (e.g. Secret Service/libsecret); fails closed otherwise
Platforms: macOS · Linux · remote/headless serversClients: Pi (pi-mono) · imports host configs from Cursor, Claude Code, Claude Desktop, Codex, VS Code, Windsurf, opencode
Documentation ↗Reviewed 2026-08-07
Topics
aiclaudecoding-agentextensionllmmcpmodel-context-protocolpi
- Stars
- 1,171★
- Forks
- 240
- Language
- TypeScript
- License
- MIT
- Created
- 2026-01-19
- Last push
- 2026-08-06