MCP Hub
Back to servers

pi-mcp-adapter

A token-efficient adapter for the Pi coding agent that reduces context window usage by replacing multiple tool definitions with a single proxy tool for on-demand discovery and execution.

Stars
13
Tools
1
Updated
Jan 20, 2026
Validated
Jan 23, 2026

Pi MCP Adapter

Use MCP servers with Pi without burning your context window.

https://github.com/user-attachments/assets/4b7c66ff-e27e-4639-b195-22c3db406a5a

Why This Exists

Mario wrote about why you might not need MCP. The problem: tool definitions are verbose. A single MCP server can burn 10k+ tokens, and you're paying that cost whether you use those tools or not. Connect a few servers and you've burned half your context window before the conversation starts.

His take: skip MCP entirely, write simple CLI tools instead.

But the MCP ecosystem has useful stuff - databases, browsers, APIs. This adapter gives you access without the bloat. One proxy tool (~200 tokens) instead of hundreds. The agent discovers what it needs on-demand.

Install

npx pi-mcp-adapter

This downloads the extension to ~/.pi/agent/extensions/pi-mcp-adapter/, installs dependencies, and configures Pi to load it. Restart Pi after installation.

Quick Start

Create ~/.pi/agent/mcp.json:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest"],
      "lifecycle": "keep-alive"
    }
  }
}

The LLM searches for tools, sees their schemas, and calls them:

mcp({ search: "screenshot" })
chrome_devtools_take_screenshot
  Take a screenshot of the page or element.

  Parameters:
    format (enum: "png", "jpeg", "webp") [default: "png"]
    fullPage (boolean) - Full page instead of viewport
mcp({ tool: "chrome_devtools_take_screenshot", args: { format: "png" } })

Two calls instead of 26 tools cluttering the context.

Config

Server Options

{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "some-mcp-server"],
      "lifecycle": "keep-alive"
    }
  }
}
FieldDescription
commandExecutable for stdio transport
argsCommand arguments
envEnvironment variables (${VAR} interpolation)
urlHTTP endpoint (StreamableHTTP with SSE fallback)
auth"bearer" or "oauth"
bearerToken / bearerTokenEnvToken or env var
lifecycle"keep-alive" for auto-reconnect
exposeResourcesExpose MCP resources as tools (default: true)
debugShow server stderr (default: false)

Import Existing Configs

Already have MCP set up elsewhere? Import it:

{
  "imports": ["cursor", "claude-code", "claude-desktop"],
  "mcpServers": { }
}

Supported: cursor, claude-code, claude-desktop, vscode, windsurf, codex

Usage

ModeExample
Searchmcp({ search: "screenshot navigate" })
Describemcp({ describe: "tool_name" })
Callmcp({ tool: "...", args: {...} })
Statusmcp({ }) or mcp({ server: "name" })

Search includes parameter schemas by default. Space-separated words are OR'd.

Commands

CommandWhat it does
/mcpServer status
/mcp toolsList all tools
/mcp reconnectReconnect servers
/mcp-auth <server>OAuth setup

How It Works

See ARCHITECTURE.md for details. Short version:

  • One mcp tool in context (~200 tokens)
  • Tool metadata stored in a map, looked up at call time
  • MCP server validates arguments
  • Keep-alive servers get health checks and auto-reconnect

Limitations

  • OAuth tokens obtained externally (no browser flow)
  • No automatic token refresh

Reviews

No reviews yet

Sign in to write a review