pi-subagent
pi-subagent
Pi CLI(
@earendil-works/pi-coding-agent)을 프로그래밍 가능한 코딩 서브 에이전트로 전환하여, 모든 MCP 호스트(ZCode, Claude Code, Cursor 등)가 작업을 위임하고, 세션을 추적하고, 프로세스를 종료할 수 있게 합니다.
pi-subagent는 pi -p --mode json을 7개의 구조화된 도구로 감싸는 경량 MCP 서버입니다: 작업 위임, 결과 수집, 스케줄링 결정, 명명된 세션 관리, 실행 중단. 프로세스 격리, 완전 세션 기반, 동기/비동기 이중 모드.
왜 필요한가
Pi는 최소한의 터미널 코딩 에이전트입니다. 이 프로젝트는 Pi에게 방법론을 가르치는 대신, Pi를 위임 가능한 작업자로 취급합니다: 호스트 에이전트(ZCode / Claude Code)가 언제 위임할지 결정하고, 자체 포함된 작업을 실행하고, 결과를 수집합니다. 하나의 Pi 프로세스 = 하나의 격리된 서브 에이전트 실행.
프로세스 격리 — 각 위임은 하나의
pi -p자식 프로세스를 생성합니다. Pi가 충돌해도 해당 실행에만 영향을 미칩니다.완전 세션 기반 — 모든 작업은 명명된 세션(예:
feat-auth)에 바인딩됩니다. 이후 호출은 자동으로 계속됩니다.동기 / 비동기 — 기본값은
async(호스트 도구 호출 시간 초과 방지).pi_status롱폴링으로 수집.스케줄 가능 —
pi_plan은 순수 5단계 결정 함수(거부 / 용량 / 재사용 / 수정 / 모드)이며, 완전히 단위 테스트됨.범용 MCP — 모든 표준 MCP 클라이언트가 로드할 수 있습니다.
Related MCP server: cursor-agent-bridge
아키텍처
┌─────────────────────────────────────────────────────────────┐
│ MCP Host (ZCode / Claude Code / Pi / Cursor …) │
└───────────────────────────┬─────────────────────────────────┘
│ MCP (JSON-RPC over stdio)
▼
┌─────────────────────────────────────────────────────────────┐
│ pi-subagent-server (Node/TS) │
│ ┌────────────┐ ┌──────────────┐ ┌────────────────────┐ │
│ │ Tool layer │ │ Session │ │ Pi runner │ │
│ │ (7 tools) │─▶│ registry │─▶│ (spawn pi -p) │ │
│ │ + plan() │ │ + persist │ │ parse agent_end │ │
│ └─────┬──────┘ │ + _snapshot │ │ + tool_execution │ │
│ │ └──────────────┘ └─────────┬──────────┘ │
│ │ ┌────────▼─────────┐ │
│ └───────────────────────────│ Run registry │ │
│ (kill) │ + process-table │ │
│ └──────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│ child_process.spawn({ cwd })
▼
┌─────────────────────┐
│ pi CLI (0.77+) │
└─────────────────────┘명확한 경계를 가진 세 개의 계층: 도구 계층(MCP 스키마 + plan() 순수 함수) / 세션 레지스트리(상태 + 영속성 + 편집) / 러너(pi 생성, NDJSON 파싱, 프로세스 테이블).
도구
도구 | 목적 |
| 결정: 위임 여부, 동기/비동기, 세션 수 |
| 작업 전달(기본 비동기, 새 세션은 핸드셰이크 대기) |
| 실행 결과 수집(롱폴링) |
| 세션 목록( |
| 단일 세션 검사 |
| 다른 경로를 시도하기 위해 세션 분기 |
| 실행 중단 |
| 다단계 작업 생성(호스트가 먼저 |
| 계획의 도메인 검토 전달( |
| 한 단계 실행: 동기(결과 대기) 또는 비동기(runId 반환) |
| 비동기 단계 실행 수집, 자동 판정 및 재전달(최대 3회), 그 외 수동 |
| 작업 목록(taskId / status로 필터링) |
검토 루프:
pi_task_plan후pi_status(runId)로 수집합니다. 실행이 완료되면 서버는 검토 실행임을 감지하고_plan-reviewed.md를 파싱하여planVerdict/planReviewedPath를 작업에 저장합니다. 단계 프롬프트는 자동으로 검토된 계획과 통과된 의존성 단계의 출력 파일을 포함합니다.
비동기 단계:
pi_task_stage_run에mode: "async"를 전달하면 전체 실행 동안 도구 호출을 차단하지 않습니다(MCP 호스트가 짧은 도구 시간 초과를 적용할 때 권장).pi_task_stage_collect(taskId, stageId)로 수집합니다. 실패한 시도는 새 세션 이름으로 재전달되어 기록 오염을 방지합니다. 3회 실패 후 단계는manual이 되며 결정 패널(promptHintOverride를 통한retry_with_new_hint지원)이 표시됩니다.
재시작 복구: 동일한
taskId로pi_task_create를 다시 실행하면 충돌 대신 병합됩니다. 출력 파일이 이미 존재하고 검증을 통과한 단계는 자동으로passed로 표시되므로, 중단된 작업은tasks.json을 수동 편집하지 않고 재개할 수 있습니다.
세션 모델
각 세션은 사람이 읽을 수 있는 이름 + Pi의 UUID +
cwd+goal을 가집니다.첫 번째
pi_delegate가 세션을 생성합니다(goal필수). 이후 호출은 자동으로 계속됩니다.레지스트리는
~/.pi-subagent/registry.json에 영속화됩니다(원자적 쓰기, 재시작 시 중단된running레코드는error로 수정).동시성 상한: 4개의 실행 중인 런. 단일 세션은 동시에 실행되지 않습니다.
작업은
~/.pi-subagent/tasks.json에 영속화됩니다(원자적 쓰기, 재시작 시 실행 중인 단계는failed(interrupted_by_restart)로 수정).
설치
git clone <this-repo> && cd pi-subagent
npm install전제 조건: pi CLI가 설치되어 있고(npm i -g @earendil-works/pi-coding-agent) PATH에 있어야 합니다.
MCP 호스트 구성
MCP 클라이언트 구성에 추가:
{
"mcpServers": {
"pi-subagent": {
"command": "npx",
"args": ["tsx", "/abs/path/to/pi-subagent/src/server.ts"]
}
}
}선택적 환경 변수:
PI_SUBAGENT_REGISTRY— 레지스트리 경로(기본값~/.pi-subagent/registry.json)PI_BIN— pi 실행 파일 재정의(테스트에서 사용)
테스트
npm test # full suite (140 tests)
npm run test:fast # dot reporter테스트는 가짜 pi(test/fixtures/fake-pi.sh)를 사용하며 다음을 다룹니다: 비동기/동기, 시간 초과, 종료, 세션 생성 실패, 다중 대기자, 진행 상한, 스케줄링 규칙(테이블 기반 + 100회 반복 속성 테스트), 레지스트리 영속성, 편집 등.
프로젝트 구조
src/
├── types.ts # all shared types + error codes
├── errors.ts # ToolError helpers
├── runner/ # parse.ts, argv.ts, spawn.ts, process-table.ts
├── registry/ # session.ts, run.ts, persist.ts, redact.ts
├── scheduler/ # keywords.ts, plan.ts (5-stage pure function)
├── tools/ # delegate, status, plan-tool, session, kill
└── server.ts # MCP entry (stdio)
skills/pi-subagent/ # SKILL.md + delegation-patterns (strategy layer)
test/ # fixtures/ + *.test.ts
docs/ # design.md (spec) + implementation-plan.md설계 및 프로세스
이 프로젝트는 협업 설계 + 구현 전 4차례의 외부 검토를 거쳤습니다. 사양과 계획은 docs/ 아래에 커밋되어 있습니다:
docs/design.md— 전체 설계 사양(아키텍처, 도구 계약, 오류 처리, 스케줄러 규칙, 테스트 전략). 모든 계약은 검토 노트(R1–R4)로 추적 가능합니다.docs/implementation-plan.md— 19개의 TDD 작업(실패 테스트 작성 → 구현 → 통과 → 커밋).
모든 주요 설계 결정은 실제 pi -p 출력 프로빙과 외부 검토에 기반합니다:
cwd≠ 세션 저장소 —spawn({ cwd })는 작업 디렉터리를 제어합니다. Pi의 세션 파일은 기본 위치를 사용합니다(프로젝트를 오염시키지 않음).비동기 기본 + 핸드셰이크 — 새 세션은
sessionStartTimeoutMs로 Pi의session이벤트를 기다린 후 반환하므로 호스트는 항상 실제piSessionId를 얻습니다.다단계 스케줄러 —
plan()은 거부 → 용량 → 재사용 → 수정 → 모드 순서이며, 수정자는 첫 번째 일치가 아닌 누적됩니다(검토 1차에서 얻은 교훈).진행 편집 — 도구 결과는 저장 전에 잘리고 토큰/키가 제거됩니다.
상태
작동하는 구현, 140개의 통과 테스트. 아직 npm에 게시되지 않음 — tsx로 소스에서 실행.
라이선스
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to spawn and control Codex CLI and Claude Code sessions on the host machine, with session management and filesystem access.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients like Claude Code to delegate coding tasks to the local Cursor Agent CLI, with persistent per-workspace sessions that resume across calls.12MIT
- AlicenseNot gradedqualityBmaintenanceDelegates bounded coding tasks from MCP clients to the Pi Coding Agent over stdio. Supports review, verification, implementation, and batch operations with long-running task polling.MIT
- AlicenseNot gradedqualityBmaintenanceEnables ChatGPT (or any MCP client) to delegate coding tasks to a local Hermes-backed agent with async job management, supporting read-only investigation, implementation, and continuation of sessions via secure MCP tunnel.1MIT
Related MCP Connectors
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/guyiicn/pi-subagent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server