npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-mcp-adapter

v7.0.0

Published

MCP (Model Context Protocol) adapter extension for Pi coding agent

Readme

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. Servers only start when you actually use them.

pi-mcp-adapter vs Pi's built-in MCP

Since then, Pi 0.99 added MCP support of its own, which also keeps tool definitions out of context. Installing the adapter replaces it in Pi sessions. What you get by switching:

  • Install many servers without paying for idle ones. The built-in starts every enabled server in every Pi session and keeps it running until the session ends. By default, the adapter starts a server when the model first calls it and stops it after 10 idle minutes.
  • More servers work fully. Servers can ask you questions through forms, show interactive UIs, offer prompt templates as slash commands, and run long jobs in the background while the agent keeps working. The built-in doesn't handle these.
  • Find tools by what you mean. The built-in's tool search only matches words. The adapter can also rank tools by meaning with a classifier model you can already use in Pi, such as Jev or Cloudflare's Clef: in a test of 12 everyday requests across 95 tools, Jev put the right tool first in 10 of 11, where word search did in 5.
  • Sign-in tokens go in your OS keychain by default (an encrypted file is opt-in), not in a plain JSON file under ~/.pi/agent.
  • Adding servers is easier. Give the agent a server's URL and it installs it and checks its tools in the same session, opening sign-in first if the server needs it, with no shell command or /reload. Servers already configured in Cursor, Claude Code, Codex, or VS Code can be imported with /mcp-adapter setup, which also adds presets such as Figma and GitHub.

The built-in turns codemode on by itself; with the adapter, add "+codemode" to defaultTools in Pi's settings. Pi's codemode works with both.

| | Pi's built-in MCP | pi-mcp-adapter | |---|---|---| | Servers running | Every enabled server, for the whole session | Only servers in use; each stops after 10 idle minutes | | Server memory (100 installed, 3 in use) | 7.0 GB at start, 5.9 GB after 15 minutes | Only the 3 in use, then none once they're idle | | How the model reaches tools | Default: codemode scripts. Per server: direct, or loaded by tool_search | Default: one mcp proxy tool. Per server: direct, or loaded by tool_search. Scripts: Pi's codemode, opt-in (add "+codemode" to defaultTools) (MCP scripting) | | Token cost | By default, every call is a codemode script | Single lookups cost about the same as the built-in's default. Bulk tasks cost up to 5.5× more without scripts, and up to 2.9× more with Pi's codemode turned on (measured) | | Tool search | tool_search, ranked by words | mcp({ search }) ranked by words or regex. With a classifier model in Pi, such as Jev through /login to OpenRouter, semantic search ranks tools by meaning (setup) | | Long tool results | A codemode script can filter a result before the model sees it | Opt-in per server: mcp({ tool, args, extract: { total: "number" } }) returns only the values you name, as numbers and dates read by Cloudflare's Clairic model with your Cloudflare credentials in Pi; the full result is saved to a file (Typed values) | | Saved workflows as tools | No | A workflow you repeat becomes one tool with fixed inputs: a saved script that calls MCP and Pi tools, found by search and called like any other tool (scriptTools, Script tools) | | Executor app tools | Only Executor's own six tools; the model reaches app tools through Executor's search and call | Each tool of your Executor apps is a Pi tool, found by search and called by name with Pi's approvals (Executor app tools) | | OAuth tokens | JSON file in ~/.pi/agent | OS keychain | | MCP prompts, elicitation, sampling, Tasks | No | Yes; Tasks run in the background and need "protocolVersion": "auto" | | MCP UI apps | Left out | Native window or browser | | Add a server | pi mcp add in a shell, then /reload | Give the agent the URL: mcp({ action: "install", url }) connects it and checks its tools in the current session; for an OAuth server it opens sign-in first and checks the tools once you approve | | Configs from Cursor, Claude Code, Codex, VS Code | Convert by hand | Imported | | Guided setup in a session | No; /mcp manages servers that are already configured | /mcp-adapter setup overlay: imports configs found on your machine, adds presets (Figma desktop and RepoPrompt when installed, GitHub, Notion, Context7, DeepWiki, Parallel Search, Tavily Search, Chrome DevTools), and previews each file change before writing | | Ask before risky tools | Through a permission extension, which sees every MCP call | Built in (approveTools); permission extensions also see each MCP call under the tool's own name | | Roots (session directory sent to servers) | Yes | Yes | | Shell commands | pi mcp add, remove, list | pi-mcp-adapter init, doctor | | Transports | stdio, streamable HTTP | stdio, streamable HTTP, legacy SSE, rmcp-mux socket |

Over a session, measured on Pi 0.99.2 with 100 small local servers:

| 100 servers installed, 3 used | Pi's built-in MCP | pi-mcp-adapter | |---|---|---| | Servers running at session start | 100 | 0 | | While you use 3 | 100 | 3 | | After the idle timeout (10 min) | 100 | 0 |

Stopping a server doesn't take its tools away: the model can still search them, and a stopped server starts again on its next call (0.1–0.3 s for a small local server). For a server that must keep state between calls, set "lifecycle": "lazy-keep-alive". The first session briefly starts new servers, 10 at a time, to read their tool lists. Measurements and details.

The full comparison has every row with sources, as of Pi 1.3.0.

When you install or update the adapter, it turns Pi's built-in MCP off in Pi's settings for you (the same switch as pi config → Built-in), so the two don't both run. If you remove the adapter, turn the built-in back on there (details).

Install

pi install npm:pi-mcp-adapter

Restart Pi after installation.

DeepSeek Harness (third-party bridge): Run the unmodified adapter in DSH via pi2dsh; see the verified dsh-TUI and Web MCP guide.

What happens on first run

The adapter reads standard MCP files automatically. No extra setup needed if you already have them.

| You already have... | What happens | |---------------------|--------------| | .mcp.json or ~/.config/mcp/mcp.json | Pi uses it immediately. Use .mcp.json for project/team sharing and ~/.config/mcp/mcp.json for all projects. | | Servers added with pi mcp add (~/.pi/agent/mcp.json, .pi/mcp.json) | On Pi 0.99 and later, the adapter uses them and replaces Pi's built-in MCP extension, which Pi reports at startup; see Pi's built-in MCP. | | Host-specific configs (Cursor, Claude Code, Codex, etc.) but no standard MCP files | Run /mcp-adapter setup to adopt those host configs into Pi. The setup flow shows exactly what it found, lets you pick which ones to import, and previews the exact file changes before writing. | | Nothing configured yet | Run /mcp-adapter setup, choose project .mcp.json or global ~/.config/mcp/mcp.json, then scaffold a minimal config, add a curated known server, quick-add RepoPrompt, or inspect what the adapter discovered on your machine. |

If you prefer the terminal, you can also run pi-mcp-adapter init after install to scan for host-specific configs and add missing compatibility imports to the adapter config (~/.pi/agent/mcp-adapter.json by default, or $PI_CODING_AGENT_DIR/mcp-adapter.json when set).

Quick Start

Add a server to .mcp.json in your project:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "[email protected]"]
    }
  }
}

Servers are lazy by default — they won't connect until you actually call one of their tools. The adapter caches tool metadata so search and describe work without live connections.

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.

Common tasks

| Want | Do | Details | |------|----|---------| | Add a server without editing JSON | /mcp-adapter setup, or mcp({ action: "install", url: "..." }) | Configuration, Install from one URL | | Use servers from Cursor, Claude Code, or Codex | /mcp-adapter setup or pi-mcp-adapter init | Import existing configs | | Sign in to an OAuth server | /mcp-auth <server> | Authentication | | Put a few tools directly in the model's tool list | "directTools": ["tool_a"] on the server | Direct tools | | Ask before a risky tool runs | "approveTools": "destructive" | Tool approval | | Keep a server running | "lifecycle": "keep-alive" | Lifecycle modes | | Hide noisy tools | includeTools / excludeTools on the server | Search-activated direct tools | | Chain many MCP calls in one step | "+codemode" in Pi's defaultTools, then codemode | MCP scripting | | Use Figma | /mcp-adapter setup, add Figma (desktop) | Setup panel |

Commands

| Command | What it does | |---------|--------------| | /mcp-adapter | Interactive panel and first-run onboarding surface | | /mcp | Same as /mcp-adapter | | /mcp-adapter setup | Guided setup for imports, a minimal .mcp.json, curated known servers, RepoPrompt quick-add, and config-path inspection | | /mcp-adapter semantic setup | Choose which servers may share tool names and descriptions with semantic search, save that choice for the project, and reload Pi | | /mcp-adapter edit [project\|global] | Open .mcp.json (default) or ~/.config/mcp/mcp.json in an editor; Ctrl+G opens $EDITOR; saves a valid JSONC object and reloads | | /mcp-adapter tools | List all tools | | /mcp-adapter prompts | List all MCP prompts registered as slash commands | | /mcp-adapter tasks [stop <server>/<taskId>] | List long-running MCP tasks still working in the background, or stop one | | /mcp-adapter reconnect | Reconnect all servers | | /mcp-adapter reconnect <server> | Connect or reconnect a single server | | /mcp-adapter disable <server> | Disable a server in the project-local .pi/mcp-adapter.json (requires /reload to apply) | | /mcp-adapter enable <server> | Enable through the project-local override layer (requires /reload to apply) | | /mcp-adapter logout <server> | Clear stored OAuth credentials for a server and disconnect it | | /mcp-auth | Open an OAuth server picker in interactive UI sessions | | /mcp-auth <server> | OAuth setup for a specific server |

If settings.autoAuth is true, mcp({ connect: ... }), mcp({ tool: ... }), and direct tool calls automatically run OAuth when needed and retry once.

In interactive sessions, you can also authenticate from /mcp-adapter with ctrl+a or Enter on a server that needs auth. /mcp-auth without a server only opens a picker in the interactive UI. For gateway authorization and manual callback completion, see Remote/headless authentication.

On Pi 0.99 and later, servers you already signed in to with Pi's built-in MCP can reuse that sign-in: the adapter asks once per server, and /mcp-adapter offers ctrl+p to import them. See Import a sign-in from Pi's built-in MCP.

How It Works

  • One mcp tool in context (~200 tokens) instead of hundreds
  • Servers are lazy by default — they connect on first tool call, not at startup
  • Tool metadata is cached to disk so search/list/describe work without live connections
  • Idle servers disconnect after 10 minutes (configurable), reconnect automatically on next use
  • npx-based servers resolve to direct binary paths, skipping the ~143 MB npm parent process
  • MCP server validates arguments, not the adapter
  • Remote keep-alive servers force-refresh their tool catalog during health checks, before user input, and before adapter-triggered turns, with bounded reconnect backoff
  • Specific tools can be promoted from the proxy to first-class Pi tools via directTools config, so the LLM sees them directly instead of having to search

Limitations

  • Each Pi session runs its own server processes; rmcp-mux can share one across sessions
  • Compact MCP result rendering summarizes text, but inline images are still controlled by Pi's image display settings and may render below the compact text summary.
  • Pi still owns one separator row before self-rendered tool output, so compact mode reduces adapter rendering height but cannot promise true zero-gap rows.
  • MCP sampling support is text-only; context inclusion, tools, stop sequences, audio, and image content are rejected with explicit errors.

Documentation

The full reference lives in docs/:

| Doc | What's in it | |-----|--------------| | Configuration | The setup panel, config files and precedence, imports from other hosts, project server trust, lifecycle modes, and every settings key. | | Server options | Every server field, custom HTTPS trust, macOS local-network access, protocol negotiation, MCP Tasks, stdio environment, rmcp-mux, and URL install. | | Authentication | OAuth setup, remote and headless sign-in, token storage, headers, bearer tokens, and secret commands. | | pi-mcp-adapter vs Pi's built-in MCP | Every difference, with sources, as of Pi 1.3.0. | | Using MCP tools | The mcp tool, search and search keywords, direct tools, tool approval, and the output guard. | | MCP scripting | Semantic tool search, and scripting MCP calls with Pi's codemode. | | Prompts, elicitation, and MCP UI | MCP prompts as slash commands, servers asking for input, and interactive MCP UI windows. | | Extension API, plugins, and SDK | Agent Plugins, Claude plugin bundles, Pi package manifests, runtime registration and tool calls, createMcpAdapter, host-managed embedding, and status events. |