
用于Pi编码代理的高效令牌MCP适配器
概览
用 MCP 服务器配合树莓派,不要烧掉上下文窗口。 https://github.com/user-attachments/assets/4b7c66ff-e27e-4639-b195-22c3db406a5a Mario写过为什么你可能不需要MCP。问题是:工具定义太冗长了。单个MCP服务器可以烧掉1万+个代币,无论你是否使用这些工具,你都在付出这笔费用。连接几个服务器,你在对话开始前就已经烧掉了一半的上下文窗口。 他的看法是:干脆跳过MCP,直接写简单的CLI工具。 但MCP生态系统有实用功能——数据库、浏览器、API。这个适配器能让你访问而不增加冗余。一个代理工具(~200个令牌)代替数百个。代理按需发现所需。服务器只有在你实际使用时才会启动。 适配器会自动读取标准MCP文件。如果你已经有MCP文件,就不需要额外设置。
概述(AI 翻译)
用 MCP 服务器配合树莓派,不要烧掉上下文窗口。
https://github.com/user-attachments/assets/4b7c66ff-e27e-4639-b195-22c3db406a5a
为什么会有这样的存在
Mario写过为什么你可能不需要MCP。问题是:工具定义太冗长了。单个MCP服务器可以烧掉1万+个代币,无论你是否使用这些工具,你都在付出这笔费用。连接几个服务器,你在对话开始前就已经烧掉了一半的上下文窗口。
他的看法是:干脆跳过MCP,直接写简单的CLI工具。
但MCP生态系统有实用功能——数据库、浏览器、API。这个适配器能让你访问而不增加冗余。一个代理工具(~200个令牌)代替数百个。代理按需发现所需。服务器只有在你实际使用时才会启动。
pi-mcp 适配器 vs Pi 内置 MCP
此后,Pi 0.99 增加了自己的 MCP 支持,这也使工具定义脱离上下文。安装适配器后,它会在 Pi 会话中取代它。切换后你得到的是什么:
- 安装多台服务器而无需为闲置服务器付费。 内置功能会在每个树莓派会话中启动所有启用的服务器,并保持运行直到会话结束。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 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
What’s new in 7.0
https://github.com/user-attachments/assets/a3fc7834-2540-45b6-a80e-d9c17125a66c
On servers that support MCP Tasks, add "protocolVersion": "auto" and slow tools run in the background while the agent keeps working. Tool search can rank tools by meaning and send full schemas only for the ones that fit. And extract hands the agent just the values it asked for from a long result. Everything else is in the changelog.
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.
安装
npx -y [email protected]配置
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "[email protected]"]
}
}
}