sub-pi-agent
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sub-pi-agent ask Pi to review the auth module and run its tests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sub-pi-agent
把任务交给可复用的 Pi agent,让主 agent 专注规划和审查。
独立的 stdio MCP 服务,适用于 Codex 和其他 MCP 客户端。支持命名 agent、跨 MCP 重启保留上下文、提问交回和运行中纠偏;等待由 MCP 处理,无需主模型反复轮询。无需 Codex App Server、桌面事件注入或专用启动器。
怎么用
例如,让 Pi 检查一个模块并运行相关测试,主 agent 同时处理其他工作。Pi 缺少信息时交回问题,主 agent 回答后继续同一个会话;任务完成后读取结果并审查,需要修改时也不用从头交代背景。
Related MCP server: pi-agent-mcp
快速开始
需要 Node.js ≥22.19.0,以及已配置模型和认证的 Pi。尚未配置时,先按 Pi 官方说明安装 CLI,运行 pi,用 /login 和 /model 完成配置。本服务内置 Pi SDK 1.2.0,读取同一套配置,不依赖全局 Pi CLI 执行任务。
1. 接入 Codex
把下面配置加到 ~/.codex/config.toml,然后重新加载 MCP:
[mcp_servers.pi]
command = "npx"
args = ["-y", "sub-pi-agent@0.1.1"]
startup_timeout_sec = 120
tool_timeout_sec = 600Windows 若无法启动 npx,将 command 改为 "npx.cmd"。其他 MCP 客户端、源码安装及配置说明。
2. 派发第一个任务
在客户端让主 agent 调用 pi_spawn_agent,传入下面的参数。将 cwd 替换为实际项目的绝对路径:
{
"name": "review-project",
"description": "梳理项目结构和测试入口",
"cwd": "/absolute/path/to/project",
"task": "阅读项目说明,概括项目结构和测试入口。不要修改文件;缺少必要信息时交回问题。"
}省略 model 使用该项目下的 Pi 默认模型。任务会调用模型,可能产生费用。
3. 等待并读取结果
保存返回的 session_id。有独立工作就继续做;没有时调用 pi_wait_agent,传入 {"session_id":"<返回的 ID>"}。
done:调用pi_get_result读取交付并审查needs_input:调用pi_poll_agent读问题,再用同一 ID 调用pi_continue_agent,将答案放在task中等待超时:任务仍在运行,可以再次等待
error/interrupted:用pi_get_result查看错误和部分结果
以上读取工具都使用同一个 session_id。任务结束后可用 pi_release_agent 卸载资源,之后仍能继续上下文。完整流程和参数见工具参考;首次接入可按冒烟测试验证。
使用边界
Pi 以启动 MCP 的本机用户权限访问文件和执行命令,没有独立沙箱;请只在可信项目中使用
会话和结果保存在本机,跨重启可恢复;MCP 退出会中断执行,需显式继续
没有反向实时通知,不会在上层聊天结束后自动唤醒主 agent
文档
安装与配置:客户端接入、模型设置优先级
工具参考:11 个工具、状态、纠偏、提问与未读提醒
数据与生命周期:存储目录、环境变量、恢复与权限
验证与排障:冒烟测试、常见错误和处理方法
开发与发布:测试、打包和发布
来源与许可
基于 Courtney Andrew Richardson 的 crichalchemist/agent-pi 1.8.0(f3ac8c1)修改,保留原版 MIT LICENSE。本版本增加持久化会话、提问交回、未读事件、等待与精简活动状态,并整理为独立 MCP/npm 入口。
Available Tools
11 toolspi_continue_agentA
Continue a registered agent by explicit ID, retaining its Pi conversation/tool context. For needs_input, pass the answer as task; otherwise pass the next assignment. Returns identity/status immediately. Do independent work or use pi_wait_agent when idle; pi_poll_agent inspects progress/questions and pi_get_result reads final delivery. Restores released sessions after MCP restart, rejects running agents, never imports arbitrary Pi CLI sessions. Omit model to follow current Pi settings.
Inputs: task (required), session_id (required), model.
pi_followup_agentA
Queue a follow-up message for a spawned Pi agent. Delivered only after the agent finishes all work. Use this when you do not want to interrupt the agent at all.
Inputs: message (required), session_id (required).
pi_get_resultA
Read final delivery, without waiting: done returns the last Pi reply, error/interrupted returns the final partial reply and error in the JSON body. Before final delivery exists, returns only {ready:false,reason,next}, never progress or a question body; use pi_poll_agent. Reading final delivery acknowledges its unread event. Results remain readable after release or MCP restart.
Inputs: session_id (required).
pi_list_agentsA
List only this MCP registry, including unloaded recoverable agents. Compact identity/status metadata, no transcript. active means running; needs_input means Pi handed back a question: poll it, then continue the same ID with an answer. Listed agents become eligible for this connection's unread event reminders. Does not refresh idle timers.
Inputs: cwd, status.
pi_list_modelsA
List Pi models available for this session with tier labels (fast/balanced/frontier).
Inputs: no named parameters.
pi_poll_agentA
Immediately read latest assistant text, compact activity metadata and any pending question, without reasoning text or raw tool records. output can stay unchanged while Pi thinks or runs tools; activity shows the latest phase/tool and its update time. needs_input returns question {id,text}: answer via pi_continue_agent on the same ID. Reading a question acknowledges its reminder; polling does not acknowledge final delivery. When idle, use pi_wait_agent instead of repeatedly polling.
Inputs: session_id (required).
pi_release_agentA
Unload an idle agent runtime and release its write lease, retaining its name, description, results and native Pi session on disk for later continuation. Rejects busy agents. Does not delete the agent or its context.
Inputs: session_id (required).
pi_spawn_agentA
Start a named Pi agent asynchronously. Returns identity/status, not a completed result. Continue independent work; when idle, call pi_wait_agent instead of repeatedly polling. pi_poll_agent reads progress or a needs_input question; answer through pi_continue_agent on the same ID. Read final delivery with pi_get_result once done. Unread events may accompany any tool response; no live notifications. Use pi_list_agents for reuse. Omit model to follow Pi settings.
Inputs: task (required), cwd, name, model, +1 more.
pi_steer_agentA
Queue a steering message for a running Pi agent. Returns the message verbatim plus a delivery status: {ok:true,message,status:"queued"} means only that Pi accepted it for delivery after the current assistant turn finishes its tool calls — it does NOT mean the message was delivered or that Pi has responded. {ok:false,message,status:"rejected",reason} means nothing was sent (unknown session, session not running, or Pi refused the steer). Use pi_followup_agent to queue a message for after all work is finished.
Inputs: message (required), session_id (required).
pi_terminate_agentA
Stop the current task, mark it interrupted, and return its partial latest reply. Retains the registered agent and context for explicit continuation; use pi_release_agent to unload an idle runtime.
Inputs: session_id (required).
pi_wait_agentA
When no independent work remains, wait for this agent to need input, finish, fail or be interrupted. The MCP process waits without calling a model; progress changes alone do not wake it. Already actionable states return immediately. Returns {status,timed_out,next}; no progress, question or delivery body, and no event acknowledgement. On timeout Pi keeps running: wait again or inspect progress. Read questions with pi_poll_agent and final delivery with pi_get_result. Cancelling the wait does not stop Pi.
Inputs: session_id (required), timeout_ms.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have clearly distinct purposes (spawn vs continue vs poll vs get_result vs terminate vs release). However, pi_steer_agent, pi_followup_agent, and pi_continue_agent all send messages to agents with subtly different timing; while descriptions clarify, an agent could still momentarily confuse which to use.
All tool names use a consistent snake_case pi_ prefix followed by verb_noun (pi_spawn_agent, pi_list_agents, pi_get_result, etc.). The pattern is predictable and readable throughout.
With 11 tools, the set is well-scoped for asynchronous agent orchestration. Each tool covers a distinct lifecycle operation (spawn, list, poll, wait, continue, steer, followup, terminate, release, get result, list models) without redundancy.
The surface covers the full agent lifecycle: creation, monitoring, interaction, termination, and release, plus model listing. The only minor gap is the absence of a permanent delete operation—release intentionally retains agents, so cleanup beyond unloading is not possible.
Maintenance
Related MCP Connectors
- aXDeprecatedio.github.ax-platform
Agent-native collaboration network: orchestrate a team of long-running agents from any MCP client.
Discover and call AI agents via MCP. Supports A2A agents and platform agents with async tasks.
Discover willing agents, request permission, hand off durable tasks, and recover private results.
Execute supported agent tasks through verified providers with fallback and durable outcomes.
Related MCP Servers
- AlicenseCqualityCmaintenanceEnables MCP hosts to delegate coding tasks to Pi CLI as a programmable sub-agent with session tracking and process management.74MIT
- FlicenseNot gradedqualityDmaintenanceEnables MCP hosts like Claude Code and Codex to spawn, manage, and interact with persistent, reusable Pi coding-agent sessions, supporting task dispatch, status checks, and session lifecycle control.4 npm-
- AlicenseAqualityBmaintenanceEnables delegating coding tasks to a pi agent as a steerable background worker, allowing mid-run redirection, follow-ups, and keeping the delegate's context isolated from your main conversation.1224 npm22MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients such as Claude Code and Codex to delegate background Pi Coding Agent tasks, inspect and steer running work, and recover saved checkpoints after server restarts.134 npm20MIT