@geohar/pi-svg-mcp

中文文档
0.10.7发布于 2026/11/10MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2745

Pi extension: run the svg-mcp MCP server via sharedserver and inject the diagram-authoring directive. Pairs with pi-mcp-adapter, which makes svg-mcp's tools reachable from Pi.

原始使用文档
文档目录6 节
  1. How it fits together
  2. Stand-down when combiner-served
  3. Install
  4. Configuration
  5. Development
  6. License

@geohar/pi-svg-mcp

A Pi extension that makes svg-mcp available to Pi: it starts the svg-mcp server (supervised by sharedserver) and injects the diagram-authoring directive into the system prompt so the agent reaches for svg-mcp's tools instead of hand-writing SVG XML.

It is the Pi counterpart of svg-mcp's Claude Code and OpenCode plugins, and shares the same server and sharedserver instance — so Pi, Claude Code, OpenCode, and Neovim all talk to one refcounted process.

How it fits together

Pi has no MCP of its own. Two pieces give it svg-mcp:

  1. pi-mcp-adapter — the Pi package that speaks MCP; it reads its own mcp.json. Install it too (pi install npm:pi-mcp-adapter).
  2. This extension — the process + directive half:
    • Run svg-mcp on session_start via sharedserver use … -- uvx svg-mcp@<v> --transport streamable-http --port …, refcounted and shared across clients (its cold start — numpy + pillow — is paid once); released on session_shutdown when reason === "quit".
    • Inject the directive on before_agent_start (analogue of CC's additionalContext and OpenCode's system.transform).

Stand-down when combiner-served

If a combiner already serves svg-mcp (the global MCP_COMBINER switch, or the per-backend MCP_COMBINER_SERVES_SVG_MCP override, which wins), the extension does not launch a standalone backend — the combiner owns svg-mcp's lifecycle. The directive still applies, since svg-mcp's tools are present via the combiner too. In that setup you register the combiner with pi-mcp-adapter (see the mcp-companion Pi extension), not svg-mcp directly.

Install

# build
npm --prefix plugins/pi install && npm --prefix plugins/pi run build
# install into Pi (symlink the package dir; uses "main": dist/index.js)
ln -sfn "$PWD/plugins/pi" ~/.pi/agent/extensions/svg-mcp
# MCP transport (skip the mcp.json when svg-mcp is combiner-served)
pi install npm:pi-mcp-adapter
cp plugins/pi/mcp.json.example ~/.config/mcp/mcp.json   # standalone only

Build-free live dev: pi -e ./plugins/pi/src/index.ts.

Configuration

svg-mcp's tool knobs use the shared SVG_MCP_* namespace (as its OpenCode plugin does), so they apply across every client. Pi-extension toggles use PI_SVG_MCP_*.

VariableDefaultEffect
SVG_MCP_PORT7731HTTP port svg-mcp serves on.
SVG_MCP_VERSION0.10.7Pin the PyPI release (uvx svg-mcp@<v>). Kept in lockstep with this package's release by scripts/bump-version.sh.
SVG_MCP_DEV—Dev checkout for uv run --project <dir> (a path, or 1 for in-repo source).
PI_SVG_MCP_NAMEsvg-mcpsharedserver instance name.
PI_SVG_MCP_GRACE1hsharedserver grace period.
PI_SVG_MCP_LOG—Capture svg-mcp's stdout/stderr (sharedserver --log-file); "none"/unset disables.
PI_SVG_MCP_MANAGEtruefalse → don't launch (assume svg-mcp runs elsewhere).
PI_SVG_MCP_INSTRUCTIONStruefalse → don't inject the directive.
PI_SVG_MCP_NOTIFYtruefalse → don't surface messages via the Pi UI.
MCP_COMBINER / MCP_COMBINER_SERVES_SVG_MCP—Combiner serves svg-mcp → don't launch a standalone backend.
SHAREDSERVER_BIN / SHAREDSERVER_LOCKDIR(auto)sharedserver binary / lock dir.

Development

npm install && npm run typecheck && npm run build

src/sharedserver-resolve.ts is vendored byte-identical from georgeharker/sharedserver via scripts/sync-vendored.sh — edit upstream, re-sync here.

License

MIT © George Harker

版本与发布记录

@geohar/pi-svg-mcp 共发布 22 个版本,首次发布于 2026/08/18;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.7latest2026/11/106 天前
0.10.62026/11/097 天前
0.10.52026/11/097 天前
0.10.42026/11/097 天前
0.10.32026/11/097 天前
0.10.22026/11/097 天前

其他发布通道:dev → 0.10.0-dev.2。

关于 @geohar/pi-svg-mcp 的常见问题

@geohar/pi-svg-mcp 是什么?

Pi extension: run the svg-mcp MCP server via sharedserver and inject the diagram-authoring directive. Pairs with pi-mcp-adapter, which makes svg-mcp's tools reachable from Pi.

如何安装 @geohar/pi-svg-mcp?

在项目目录运行 npm install @geohar/pi-svg-mcp,或使用 pnpm add / yarn add / bun add。

@geohar/pi-svg-mcp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@geohar/pi-svg-mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@geohar/pi-svg-mcp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@geohar/pi-svg-mcp 可以商用吗?

@geohar/pi-svg-mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@geohar/pi-svg-mcp 的下载量有多少?

根据 npm 官方下载统计,@geohar/pi-svg-mcp 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,745 次,日均约 92 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@geohar/pi-svg-mcp 还在维护吗?

最新版本 0.10.7 发布于 2026/11/10(6 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。