Single-Proxy MCP: Reclaiming Context for Pi Agents
Potential replacement for the current MCP bridge in pi-tools, giving joelclaw's long-running agent workflows a token-light tool path with lazy server activation and cached discovery.
Tool sprawl is where you lose context first. pi-mcp-adapter gives Pi a way to consume Model Context Protocol servers through a single proxy tool, so you don’t pay for the whole MCP surface every turn. That matters because the same idea that made Mario Zechner write about MCP overhead is now practical in pi-tools: keep capability but drop schema weight.
The clever part is in lifecycle and metadata. Searches and descriptions use cached schemas, so mcp({ search: "..." }) can still work before any server is live, then servers come up lazily and drop idle when configured. It supports both stdio and HTTP-style MCP endpoints, with lifecycle and idleTimeout controls that keep expensive adapters from burning resources unnecessarily.
For practical control, directTools is the second big lever. You can keep the proxy-only default and selectively promote only the tools you need into the agent’s direct surface, plus use global and per-server overrides, imports from Cursor, Claude Code, Claude Desktop, and VS Code, and manage everything through the interactive /mcp overlay. In other words: this is the missing piece if you want the same behavior across global and project configs without paying a token tax at every conversation start.
Key Ideas
- Token compression by design: one
mcptool (~200 tokens exposed) replaces hundreds of verbose MCP tool signatures, directly addressing context-window pressure during agent loop runs. - Lazy lifecycle + cache: server startup is deferred until first use, while cached metadata in
~/.pi/agent/mcp-cache.jsonenables fast discovery and describe flows. - Transport flexibility:
stdioand HTTP transport options let you integrate local binary servers (vianpx) and remote MCP endpoints without changing the Pi-facing tool model. - Controlled promotion via
directTools: promote all, some (string[]), or none of a server’s tools to reduce prompt cost while keeping important commands directly callable. - Operational ergonomics:
/mcp, reconnect commands, OAuth flow hooks, and imported configs reduce local setup overhead when switching between Claude, Cursor, and VS Code MCP ecosystems. - Adapter-friendly replacement path: directly aligns with Joel’s note that it should replace the current
mcp-bridgein pi-tools.