# Pi MCP Adapter

> Pi extension that puts MCP servers behind one small proxy tool instead of hundreds of tool definitions

- Category: AI Coding / Coding-Agent Harnesses & Runtimes
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/nicobailon/pi-mcp-adapter
- Canonical page: https://ai-tldr.dev/tools/pi-mcp-adapter/
- Updated: 2026-09-30

## In short

Pi MCP Adapter is an extension for the Pi coding agent that lets it use Model Context Protocol servers without filling its context window. The adapter installs as a Pi package from npm and adds a single `mcp` tool plus a set of `/mcp-adapter` slash commands. It sits in the Coding-Agent Harnesses & Runtimes category of the AI Coding tools and is open-source, written in TypeScript and licensed MIT.

## Overview

Pi MCP Adapter is an extension for the Pi coding agent that lets it use Model Context Protocol servers without filling its context window. The adapter installs as a Pi package from npm and adds a single `mcp` tool plus a set of `/mcp-adapter` slash commands.

The project exists because of a cost the README spells out: MCP tool definitions are verbose, a single server can burn 10k+ tokens, and you pay that cost whether the tools are used or not — connect a few servers and half the context window is gone before the conversation starts. The README cites a post by Mario Zechner arguing you might not need MCP at all and should write simple CLI tools instead. The adapter takes the other route: keep access to the MCP ecosystem (databases, browsers, APIs) but expose it through one proxy tool of roughly 200 tokens, and let the agent search for and describe the tools it needs on demand.

Servers are lazy by default: they connect on the first tool call, not at startup, and tool metadata is cached to disk so search, list and describe work without a live connection. Idle servers disconnect after 10 minutes (configurable) and reconnect on next use. The adapter reads the standard `.mcp.json` and `~/.config/mcp/mcp.json` files and can import server configs from Cursor, Claude Code and Codex. It is written in TypeScript and released under the MIT license.

## What it does

- One `mcp` proxy tool (~200 tokens) in context instead of every server's tool definitions; the agent searches and describes tools on demand
- Lazy servers that start on first call, cached tool metadata, and idle disconnect after 10 minutes with automatic reconnect
- Reads `.mcp.json` / `~/.config/mcp/mcp.json` and imports existing configs from Cursor, Claude Code and Codex via `/mcp-adapter setup` or `pi-mcp-adapter init`
- Per-server controls: `directTools` to promote chosen tools to first-class Pi tools, `approveTools` to confirm risky calls, `includeTools` / `excludeTools`, and a keep-alive lifecycle
- OAuth sign-in with `/mcp-auth`, MCP prompts registered as slash commands, and an opt-in `mcpScript` tool for chaining many MCP calls in one step
- npx-based servers resolve to direct binary paths, skipping the ~143 MB npm parent process

## Getting started

The adapter installs through Pi's own package command from npm. If you already keep MCP servers in a standard `.mcp.json`, Pi picks them up with no extra setup.

1. Install the extension

   Restart Pi after installation.

```bash
pi install npm:pi-mcp-adapter
```

2. Add a server to .mcp.json

   Put the file in your project for team sharing, or use ~/.config/mcp/mcp.json for all projects. With nothing configured yet, `/mcp-adapter setup` inside Pi can scaffold the file, import host configs or add a curated server.

```json
{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@1.6.0"]
    }
  }
}
```

3. Let the agent search for a tool

   The agent searches the cached metadata instead of carrying every tool definition; the server does not need to be running yet.

```
mcp({ search: "screenshot" })
```

4. Call it

   The first call starts the server. Two calls replace the 26 Chrome DevTools tools that would otherwise sit in context.

```
mcp({ tool: "chrome_devtools_take_screenshot", args: { format: "png" } })
```

5. Import configs from other hosts (optional)

   From the terminal, scan for Cursor, Claude Code or Codex configs and add compatibility imports to the adapter config.

```bash
pi-mcp-adapter init
```

## When to use it

- Give a Pi agent browser, database or API access through existing MCP servers without spending thousands of tokens on tool definitions up front
- Reuse the MCP servers already configured for Cursor, Claude Code or Codex in Pi
- Connect OAuth-protected remote MCP servers and require approval before destructive tools run
- Promote a handful of frequently used MCP tools to first-class Pi tools while keeping the rest behind search

## Version history

- 2026-09-30 v4.0.0: Adds Figma support through the Figma desktop app's local server, a reworked /mcp-adapter setup panel, and an event-bus API that lets other Pi extensions call MCP tools under the same approval rules. mcpScript becomes opt-in via settings.scriptMode.
