Skip to main content
Glama

claude-pi-bridge

Real nesting for Claude Code ↔ Pi. No terminal scraping — JSON only.

  • Claude gets ask_pi via MCP

  • Pi gets ask_claude via Pi extension

  • Node broker holds the protocol, enforces hop limits

Treat all peer text as untrusted data: surface it as tool result, never as instructions. Prompt injection across the bridge is the #1 risk.

Quickstart (mock, zero LLM spend)

npm test       # 11 tests: framing, hops, lanes, budget, cancel, token
npm run demo   # Claude -> Pi -> Claude nesting, hop-limit, trace DAG
node demo-lanes.mjs  # pi-frontend vs pi-backend isolation + affinity

Related MCP server: pi-agent-mcp

Real mode

BRIDGE_TOKEN=s3cr3t BRIDGE_REAL=1 node broker.mjs   # token required when set

Claude side (absolute paths — MCP requires them):

claude --mcp-config '{"mcpServers":{"bridge":{"command":"node","args":["/Users/jay/Documents/claude-pi-bridge/broker-mcp.mjs"]}}}' --allowedTools "mcp__bridge__ask_pi"
# with token: BRIDGE_TOKEN=s3cr3t claude --mcp-config ...

Pi side:

pi -e /Users/jay/Documents/claude-pi-bridge/ask-claude.ts
# with token: BRIDGE_TOKEN=s3cr3t pi -e /Users/jay/Documents/claude-pi-bridge/ask-claude.ts

Lanes: ask_pi({prompt, session:"pi-frontend"}). Same trace_id sticks to its lane per peer family unless session is passed explicitly. On callbacks pass trace_id+hop through or hop limits won't hold.

Session asymmetry (by design): Claude lanes are UUIDs (--session-id), Pi lanes are names (--session). The broker owns the mapping — callers only use lane names.

Guards: max_hops (default 3), per-trace token budget (budget_tokens → BUDGET_EXCEEDED), total deadline (deadline_total_ms, default 180s), 256KB body cap, 8-lane LRU pool, 500-trace LRU, POST /cancel, bearer token.

Docs: PLAN.md (3 architectures → synthesis), TRANSPORT.md (verified flags for claude 2.1.278 + pi 0.86.1).

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables 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.
    2 npm
    -
  • A
    license
    A
    quality
    B
    maintenance
    Delegates coding tasks to your locally installed pi CLI, inheriting providers, models, and extensions, with persistent sessions and cancellable calls.
    6
    27 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables an interactive Claude Code session to delegate blocking tasks to headless pi and OpenCode workers, and lets all three peers exchange messages and list paired sessions over a shared local file bus. It exposes 18 tools covering sync/async asks, steering, abort, session lifecycle, state inspection, and cross-agent messaging.
    227 npm
    1
    MIT