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: switchboard

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).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      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.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables a coding agent such as Codex or Claude Code to delegate work to a local Pi coding-agent session, including second-opinion reviews, bulk reading kept out of the main context, and follow-up turns that retain context. Operators control what is possible by defining workspace and execution-profile aliases in a local config file, so clients cannot choose directories, models, providers, or permission levels themselves.
      429 npm
      1
      MIT