nicobailon/pi-mcp-adapter

Token-efficient MCP adapter for Pi coding agent

Pi MCP Adapter is a plugin for the Pi AI coding agent. It solves a real pain: MCP (Model Context Protocol) servers — which give AI agents access to databases, browsers, APIs — ship with verbose tool definitions that can burn 10,000+ tokens of context per server before you even use anything. Connect a few servers and you've eaten half your context window.

The adapter's trick: instead of loading every tool from every server into the agent's context, it exposes one proxy tool (~200 tokens). When the agent actually needs a specific capability, it calls the proxy, which discovers and invokes the right tool on demand. Servers are lazy — they don't even connect until you call one of their tools. Tool metadata is cached so search and describe work without live connections.

Installation is one command: pi install npm:pi-mcp-adapter.

Configuration uses standard MCP files (.mcp.json for projects, ~/.config/mcp/mcp.json for user-global) plus Pi-specific override files. A /mcp panel handles setup, and /mcp setup can adopt configs from other hosts (Cursor, Claude Code, Codex) into Pi. The adapter also supports:

  • Agent Plugins — load MCP servers from plugin packages, prefixed as <plugin>__<server>
  • Claude plugins — opt into MCP servers and skills from local plugin directories (explicit trust boundary; it never downloads or installs plugins)
  • Pi packages — ship MCP servers inside a Pi package without a separate config file
  • Programmatic usecreateMcpAdapter({ config }) for SDK/server integrations that own their MCP config
  • OAuth — a shared pi-mcp-adapter/oauth module lets cooperating extensions reuse URL-bound OAuth tokens
  • Event bus — extensions can subscribe to a versioned channel for read-only server status snapshots

Security details: the adapter never rewrites external host files, never silently launches commands from them, rejects plugin symlinks that escape their directory, and keeps OAuth flow secrets (CSRF state, PKCE verifiers) flow-local. Disabling a server only writes a disabled flag to the project-local override — the source file is untouched.

Why it matters: it gives you access to the MCP ecosystem without the context-window tax, letting the agent discover tools on demand rather than preloading everything.

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project