pi-codemode-mcp
An MCP extension that allows coding agents to manage and compose MCP tools by executing JavaScript in a sandboxed environment. It features tools for listing available MCP capabilities and a management command for handling authentication and tool policies.
README
pi-codemode-mcp
Pi extension that exposes MCP through two tools:
list_mcp_tools— enumerates all MCP tools (shows first 20 inline, overflows full list to a temp file)call_mcp— runs JavaScript in a sandbox and lets the script call MCP servers
It also adds a /mcp command for status, enable/disable, reconnect, and auth setup.
Why?
This was an experiment to see if there is an efficiency benefit of allowing a coding agent interface with MCP in a way that allows composition. See this blog post.
The actual findings are that with how MCP works today, such efficiency gains are not useful. On the other hand an MCP server that uses code internally can be very helpful. See for instance an example MCP server that uses a JavaScript environment to call Google services. That one actually performs as well as a similar skill does.
Configuration files
Loaded in merge order (later overrides earlier):
~/.pi/agent/mcp.json~/.pi/agent/.mcp.json<cwd>/.pi/mcp.json<cwd>/.mcp.json
You can override with --mcp-config /path/to/file.json.
list_mcp_tools
Parameters:
query(optional): case-insensitive text match, or regex via/pattern/flags
The tool always shows the first 20 matches inline. If more matches exist, it writes the full list to a temp .tsv file so the agent can grep/rg it.
Each listed MCP tool includes a compact schema signature, with required fields marked by * and optional fields in brackets.
Only currently enabled MCP tools are listed.
/mcp command
Use /mcp to manage MCP from interactive mode:
/mcp— opens an interactive select menu (status, reconnect, auth, and per-server tool toggles)/mcp status— show server connection/auth state + enabled/disabled counts/mcp enable <server> <tool|all>— enable a specific MCP tool (or all tools for server)/mcp disable <server> <tool|all>— disable a specific MCP tool (or all tools for server)/mcp reconnect [server]— reconnect one/all servers and refresh metadata/mcp auth <server>— trigger auth setup flow
Tool enable/disable policies are persisted in:
~/.pi/agent/mcp-tool-policies.json
Auth behavior
- OAuth flow (standard MCP auth)
/mcp auth <server>starts an OAuth browser login flow with localhost callback (for URL-based servers).- received tokens are stored in:
~/.pi/agent/mcp-oauth/<server>/tokens.json - then the server is reconnected.
- if a server's auth metadata does not support dynamic client registration,
/mcp authfalls back to bearer setup for the current session (for GitHub Copilot MCP, it will trygh auth tokenautomatically).
- Bearer servers (
auth: "bearer"or bearer token config)- if
bearerTokenEnvis configured,/mcp auth <server>lets you paste a token into that env var for the current pi process. - if no
bearerTokenEnv, it stores token in memory for the current session.
- if
For OAuth servers that require pre-registered clients, you can provide:
oauthClientIdoauthClientSecret(optional)oauthClientMetadataUrl(optional)oauthTokenEndpointAuthMethod(optional)
in the server config entry.
call_mcp
call_mcp takes JavaScript code only (plus optional timeout/state reset). Prefer batching: solve each user task in one script and use Promise.all for independent calls. Inside the script:
await call(server, tool, args)await readResource(server, uri)listTools(query?)servers(array of configured server names)tools(map of server -> tool names)resources(map of server -> resources)state(persistent mutable object across calls)
Only tools currently enabled in MCP policy are visible/callable from call_mcp.
call(server, tool, args) throws on MCP tool errors (instead of returning nested isError) and includes parameter hints from schema. It also attempts one snake_case → camelCase retry for validation errors.
Example:
const screenshots = await call("chrome-devtools", "take_screenshot", { format: "png" });
const repos = await call("github", "search_repositories", { query: "pi-mono" });
return {
screenshot: screenshots,
repos,
knownServers: servers,
firstChromeTools: tools["chrome-devtools"]?.slice(0, 10)
};
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。