pi-mcp-adapter  by nicobailon

Token-efficient adapter for integrating MCP servers with AI agents

Created 2 months ago
336 stars

Top 82.0% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a token-efficient adapter for the Pi coding agent, enabling seamless integration with Model Context Protocol (MCP) servers. It addresses the significant context window bloat caused by verbose MCP tool definitions, allowing users to leverage powerful MCP services like databases and APIs without sacrificing valuable LLM context. The adapter benefits Pi agent users by drastically reducing overhead and enabling on-demand activation of MCP servers.

How It Works

The core innovation lies in replacing hundreds of individual MCP tool definitions with a single, lightweight proxy tool (~200 tokens). Servers are configured for "lazy" lifecycle by default, meaning they only establish a connection upon their first tool call, rather than at agent startup. Tool metadata is cached locally to facilitate efficient searching and description without requiring live server connections. This approach minimizes initial resource consumption and context window usage, activating server resources only when needed.

Quick Start & Requirements

  • Installation: Run pi install npm:pi-mcp-adapter and restart Pi.
  • Configuration: Create ~/.pi/agent/mcp.json to define MCP servers, specifying their commands and arguments (e.g., npx -y chrome-devtools-mcp@latest).
  • Prerequisites: Requires npm and the Pi coding agent environment.
  • Documentation: Configuration options and examples are detailed within the README.

Highlighted Details

  • Token Efficiency: Consolidates numerous MCP tools into a single proxy, saving significant context window space.
  • Lazy Loading & Idle Timeout: Servers activate on demand and can be configured to disconnect after a specified idle period (default 10 minutes) to conserve resources.
  • Direct Tools: Allows specific MCP tools to be registered directly within the Pi agent's toolset, bypassing the proxy for potentially faster access, though each direct tool adds ~150-300 tokens to the system prompt.
  • UI Integration: Supports MCP UI standard, rendering interactive UIs natively on macOS (via Glimpse) or in a browser, with bidirectional communication capabilities for collaborative agent-UI interactions.
  • Interactive Management: The /mcp command provides an interactive panel for server status, tool toggling, and OAuth setup.
  • Configuration Import: Supports importing existing MCP configurations from other environments (e.g., cursor, claude-code).

Maintenance & Community

Information regarding maintainers, community channels (e.g., Discord/Slack), or project roadmaps is not provided in the README.

Licensing & Compatibility

The license type and any associated compatibility notes for commercial use or closed-source linking are not specified in the README.

Limitations & Caveats

OAuth token management lacks browser-based flows and automatic refresh capabilities. Cross-session server sharing is not implemented, with each Pi session managing its own server processes independently. Promoting tools via directTools incurs a per-tool token cost in the system prompt.

Health Check
Last Commit

5 hours ago

Responsiveness

Inactive

Pull Requests (30d)
14
Issues (30d)
10
Star History
160 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.