DP

dmmulroy/pi-mcp

浏览器自动化

本页由 AI 翻译,技术细节请以原文为准。 查看原文

27 stars 6 forks 质量 58 趋势 19

Pi 扩展,支持开放代码风格的 MCP 客户端

概览

Pi扩展将OpenCode风格的MCP客户端支持移植到Pi上。 Pi-MCP 需要 Node.js 20 或更新版本。它在可用时协商无状态的 MCP 2026-07-28 协议,并自动退回到兼容的 2025 时代服务器。 该扩展读取兼容 OpenCode 的 MCP 配置,顺序如下: 1. PI_MCP_CONFIG为JSON字符串或JSON/JSONC文件路径 2..pi/mcp.json 或 .pi/mcp.jsonc 3.opencode.json,opencode.jsonc,.opencode/opencode.json,.opencode/opencode.jsonc 4.~/.pi/agent/mcp.json 或 ~/.pi/agent/mcp.jsonc 在直接工具模式下,启动:“懒惰”表示启动时MCP工具未注册。打开/mcp,选择服务器,按c连接,按r重新加载配置并连接启用服务器。使用启动:“eager”,如果你希望直接MCP工具自动显示且不阻碍Pi启动。 在代理工具模式下,MCP 网关会立即注册。启动时,“懒惰”模式,它按需连接启用的服务器。

概述(AI 翻译)

Pi扩展将OpenCode风格的MCP客户端支持移植到Pi上。

要求

Pi-MCP 需要 Node.js 20 或更新版本。它在可用时协商无状态的 MCP 2026-07-28 协议,并自动退回到兼容的 2025 时代服务器。

安装

摘自GitHub:

临时演出:

配置

该扩展读取兼容 OpenCode 的 MCP 配置,顺序如下:

  1. PI_MCP_CONFIG 作为 JSON 字符串或 JSON/JSONC 文件的路径
  2. .pi/mcp.json 或 .pi/mcp.jsonc
  3. opencode.json, opencode.jsonc, .opencode/opencode.json, .opencode/opencode.jsonc
  4. ~/.pi/agent/mcp.json 或 ~/.pi/agent/mcp.jsonc

支持的平面OpenCode图形:

还支持:

startup 控制连接时序:

在直接刀具模式下,startup: "lazy" 表示 MCP 工具不注册于 启动。打开/mcp,选择服务器,然后按c连接,或按r 以重新加载配置并连接启用的服务器。使用 startup: "eager" 如果你想让直接的MCP工具自动显示而不阻碍Pi启动。

在代理工具模式下,mcp 网关立即注册。其中 startup: "lazy",它按需连接启用的服务器。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

pi-mcp

Pi extension that ports OpenCode-style MCP client support to Pi.

Requirements

Pi-MCP requires Node.js 20 or newer. It negotiates the stateless MCP 2026-07-28 protocol when available and automatically falls back to compatible 2025-era servers.

Install

From GitHub:

pi install git:github.com/dmmulroy/pi-mcp

For a temporary run:

pi -e /Users/dmmulroy/Documents/pi-mcp

Configuration

The extension reads OpenCode-compatible MCP config from, in order:

  1. PI_MCP_CONFIG as a JSON string or path to a JSON/JSONC file
  2. .pi/mcp.json or .pi/mcp.jsonc
  3. opencode.json, opencode.jsonc, .opencode/opencode.json, .opencode/opencode.jsonc
  4. ~/.pi/agent/mcp.json or ~/.pi/agent/mcp.jsonc

Supported flat OpenCode shape:

{
  "mcp": {
    "playwright": {
      "type": "local",
      "command": ["npx", "-y", "@playwright/mcp"],
      "enabled": true,
      "timeout": 30000
    },
    "docs": {
      "type": "remote",
      "url": "https://example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${DOCS_TOKEN}"
      }
    }
  }
}

Also supported:

{
  "mcp": {
    "timeout": 30000,
    "startup": "lazy",
    "servers": {
      "playwright": {
        "type": "local",
        "command": ["npx", "-y", "@playwright/mcp"]
      }
    }
  }
}

startup controls connection timing:

In direct tool mode, startup: "lazy" means MCP tools are not registered at startup. Open /mcp, select a server, and press c to connect it, or press r to reload the configuration and connect enabled servers. Use startup: "eager" if you want direct MCP tools to appear automatically without blocking Pi startup.

In proxy tool mode, the mcp gateway registers immediately. With startup: "lazy", it connects enabled servers on demand.

"eager" starts connecting enabled servers in the background after Pi startup. Eager connects run in parallel and do not block Pi’s session_start handler.

${ENV_VAR} placeholders in environment, headers, url, and cwd are expanded from the process environment.

Command

/mcp opens a keyboard-driven server manager inspired by Pi’s worktree manager. It shows connection, OAuth, tool, prompt, resource, target, and configuration details without adding a separate slash command for every operation.

  • ↑/↓ selects a server.
  • enter or c connects or reconnects it.
  • d disconnects it for the current runtime.
  • a starts OAuth when available.
  • l confirms and removes stored OAuth credentials.
  • p selects and sends one of the server’s prompts.
  • r reloads configuration and reconnects enabled servers.
  • esc closes the manager.

Outside TUI mode, /mcp reports the current server statuses without opening the interactive manager.

In direct tool mode, connected MCP tools are registered as Pi tools using OpenCode’s sanitized name convention:

_
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →