Skip to main content
Glama

pi-mcp

MCP 服务器,暴露 pi 编码代理工具:

read, bash, edit, write, grep, find, ls

使用 Bun 和 @modelcontextprotocol/server v2 构建。同时支持 2026-07-28 时代(server/discover)和 2025 时代的 initialize。

要求

  • Bun >= 1.2

  • rg 和 fd 在 PATH 上(由 grep / find 使用;不下载)

Related MCP server: emcp

安装

使用绝对路径。不要传递 . — Bun 的全局安装器可能会向 ~/.bun/install/global/package.json / bun.lock 写入重复的 pi-mcp 键和空的 "": "." 条目(oven-sh/bun#19559、oven-sh/bun#24207)。

bun add -g /absolute/path/to/pi-mcp
# same thing from the checkout:
bun add -g "$(pwd)"

bun install -g 是 bun add -g 的别名;路径才是关键。二进制文件以 pi-mcp 的形式出现在 PATH 上(~/.bun/bin)。

对于本地开发,请在此目录中改用 bun link。

用法

pi-mcp                         # stdio (default)
pi-mcp --http --port 3000      # Streamable HTTP
pi-mcp --cwd /path/to/project
pi-mcp --readonly              # read, grep, find, ls
pi-mcp --tools read,grep,ls
pi-mcp --shell /bin/bash

Flag

Meaning

--stdio

通过 stdin/stdout 提供服务(默认)

--http

提供 Streamable HTTP 服务

--host <host>

HTTP 绑定主机(默认 127.0.0.1;隐含 HTTP)

--port <port>

HTTP 绑定端口(默认 3000;隐含 HTTP)

--cwd <dir>

工具工作目录

--readonly

仅注册只读工具

--tools <names>

逗号分隔的子集

--shell <path>

用于 bash 的 Bash 可执行文件

--allowed-hosts <h>

用于 HTTP DNS 重绑定保护的逗号分隔的 Host 名称

--stdio 不能与 --http / --host / --port 组合使用。

日志输出到 stderr。stdout 是 stdio 协议通道。

主机配置(stdio)

{
  "mcpServers": {
    "pi": {
      "command": "pi-mcp",
      "args": ["--cwd", "/path/to/project"]
    }
  }
}

HTTP

pi-mcp --http --host 127.0.0.1 --port 3000

向监听器发送 POST JSON-RPC。现代(2026-07-28)客户端使用 server/discover 以及每个请求的 _meta 信封和 Mcp-Method / MCP-Protocol-Version 头。2025 客户端使用 initialize。

工具

Tool

Role

read

读取文本文件或图像(对于大文件使用 offset / limit)

bash

在 --cwd 中运行 shell 命令

edit

精确文本替换(与 pi 相同的强制转换:JSON 字符串 edits、单个编辑对象、旧版 oldText/newText)

write

创建/覆盖文件,并创建父目录

grep

使用 rg 搜索文件内容

find

使用 fd 匹配文件

ls

列出目录

执行行为取自 pi 的编码代理工具。不包括 TUI 渲染、photon 图像调整大小以及自动 rg/fd 下载。

开发

bun install
bun src/cli.ts --help

运行时依赖:@modelcontextprotocol/server、zod、diff。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A comprehensive MCP server providing secure tools for filesystem operations, Git management, web search, document conversion, npm/.NET project management, and AI generative capabilities (image/video/audio generation and processing) via PiAPI.ai integration.
    Apache 2.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    MCP server providing filesystem operations, shell execution, and web search capabilities.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Local MCP server enabling Codex and ChatGPT to read/write files, execute commands, manage processes, use Git, and inspect images on the user's machine with full privileges.
    Apache 2.0