pi-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PI_MCP_DB | Yes | Path to the SQLite database used by pi-mcp (e.g. /tmp/pi-mcp.sqlite3). | |
| PI_MCP_MODEL | No | Default model name used when run is called without a model argument. | deepseek-flash |
| PI_MCP_PROVIDER | No | Default provider name used when run is called without a provider argument. | deepseek |
| PI_MCP_CHILD_MCP | No | Set to 0 to disable the child MCP endpoint and generated config. | 1 |
| PI_MCP_AGENTS_DIR | No | Artifact root directory for agent artifacts. Defaults to <db-parent>/agents. Can also be set with --agents-dir. | |
| PI_MCP_ACCESS_TOKEN | Yes | Access token that the main transport process is bound to. | |
| PI_MCP_REFRESH_PAUSE | No | Background refresh pause in seconds for live agents. 0 disables the background thread. Can also be set with --refresh-pause. | 1 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Run and message bwrap-caged pi agents over JSONL RPC. Agents are isolated by the PI_MCP_ACCESS_TOKEN used to start the server. Each agent's /tmp is forwarded to a host directory; use list_tmp, grep_tmp, and read_tmp to inspect or download files written there. read selects stdout or errors and uses the same line/byte range controls. Each agent gets AGENT_ID in its environment. To chain agents, call run with callback_agent_id=AGENT_ID; when the child settles, pi-mcp prompts the callback with its agent_id and artifacts. Use rip to stop a process without deleting its session, and resurrect to start it again with the same provider, model, context, mounts, and callback settings. Children cannot widen mounts beyond the agent that started them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| listA | List every agent session visible to this access token. |
| get_infoB | Get metadata for one agent session: state, message counts, token usage, session/file sizes, log sizes, artifact paths, callback delivery, and last error. |
| runA | Spawn a bwrap-caged pi agent in RPC mode with optional write/read/denied mount rules. The agent starts idle and waits for send_message. Returns immediately. The agent's /tmp is forwarded to its artifact directory and can be inspected with list_tmp, grep_tmp, read_tmp, read, grep, and get_info. Inside an agent, AGENT_ID names itself; call run(callback_agent_id=AGENT_ID) to have pi-mcp prompt you with the child's result and artifact paths when it settles. Pass access_token to put the child in that token's group and patch only its MCP config. Pass context_size to lower this agent's pi context budget so autocompaction starts during long runs. When called by a caged agent, requested mounts are narrowed to that agent's mounts. |
| ripA | Stop an agent's process while keeping its record, session, logs, forwarded /tmp, and spawn settings. Repeated calls are idempotent. Counts toward lifecycle.rips. |
| resurrectA | Start a ripped or exited agent again with its stored provider, model, context_size, mounts, group, session, and callback settings. Props cannot be changed. Optionally pass a prompt to start a turn immediately. Counts toward lifecycle.retries. |
| send_messageA | Send a message to a live agent. When the agent is idle the message starts a new turn; when it is running, mode follow_up queues it for the next turn and mode steer interrupts after the current assistant turn. Returns after acceptance. |
| removeA | Stop a caged agent if it is still running, then delete its record and artifacts. |
| grepA | Proxy the host's real grep binary against an agent log stream. args is passed as an argv array with no shell, e.g. ['-in', 'pattern'] or ['-c', '-E', 'a|b']. stream selects stdout or errors; that log path is appended as the final grep file operand. Returns exit code, stdout, and stderr. |
| list_tmpA | List files and directories in an agent's forwarded /tmp with type, size in bytes, and mtime. Paths are relative to that agent's tmp directory; traversal or symlinks escaping it are rejected. |
| grep_tmpA | Proxy a call to the host's real grep binary against an agent's forwarded /tmp. args is passed as an argv array with no shell. cwd selects a directory under tmp; path optionally appends a file (relative to cwd) to grep. Use relative paths, e.g. args=['-rn', 'pattern', '.'] or args=['-n', 'pattern'] with path='file.txt'. Returns exit code, stdout, and stderr. |
| read_tmpA | Read or download a file from an agent's forwarded /tmp. Line mode uses lines_from/lines_to (0-based, end exclusive), max_lines, and max_bytes; byte mode uses bytes_from/bytes_to and is mutually exclusive with line ranges. Long lines over 10k chars are truncated with a marker, warning, and byte offsets. Text is utf-8; binary data is base64. |
| readA | Read an agent log stream selected by stream=stdout|errors. Uses lines_from/lines_to (0-based, end exclusive), max_lines, and max_bytes, or bytes_from/bytes_to. Long lines over 10k chars are truncated with a marker, warning, and byte offsets. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 12 tools
Most tools target a clearly distinct operation (spawn, stop, restart, delete, message, list, inspect). The paired tools read/grep (log streams) versus read_tmp/grep_tmp/list_tmp (forwarded /tmp) and rip versus remove overlap conceptually but are explicitly differentiated in their descriptions.
There is a semi-predictable pattern where inspect tools use a _tmp suffix (list_tmp, grep_tmp, read_tmp) mirroring the base tools (list, grep, read). However, bare verbs (run, rip, resurrect, remove) are mixed with get_/send_message forms, and the unqualified 'list' and 'read' are vague in isolation.
Twelve tools map cleanly onto agent lifecycle (run, send_message, rip, resurrect, remove) plus inspection of logs and artifacts (list, get_info, read, grep, list_tmp, grep_tmp, read_tmp). Each tool earns its place and the surface is well-scoped.
The full session lifecycle is covered — spawn, message, interrupt, stop, restart, delete — along with rich log and /tmp inspection. Gaps are minor: no wait/poll tool for agent completion (relies on callback_agent_id) and no way to mutate stored props, which appears intentional.