cli-bridge
It is an MCP server that lets an AI assistant delegate tasks to other installed AI CLIs (Claude Code, Codex, Gemini, etc.) as subprocesss, with read-only consultation and safe code-writing modes.
Consult CLIs:
ask_<lane>(e.g.ask_gemini,ask_gpt,ask_apple) sends tasks to individual AI CLIs and returns a thread id for multi-model conversations;conversationslists/replays threads.Fan-out and routing:
ask_allruns every free lane in parallel,ask_cascadegoes cheapest→strongest, andask_bestuses a learned router.Write code safely:
ask_buildreturns a worktree diff (isolated) or applies zone-guarded, lock-protected real writes (direct), with optional async steering viajob.Review and plan:
review_diffdoes multi-model security/code reviews,debateruns blind peer-ranked answers,workflowprovides presets likeconvergeandpremortem, andgit_textgenerates commit/PR messages.Operate and manage:
jobcontrols async jobs,rate_laneteaches the router,set_lane_costrecords costs,reset_lane_stateclears cooldown/failures,doctor --deepprobes lane health, andsetupwalks through cost-profile configuration.Monitor usage:
usage_report,usage_budget, andlane_statsreport runs, failures, latency, cooldowns, estimated tokens/credits, and daily-limit enforcement.
Allows using Apple's on-device AI CLI for vision tasks and offline inference.
Allows using Google's Gemini CLI with 1M-token context, fresh knowledge, and vision.
Allows running local AI models via Ollama for free cross-checks and offline tasks.
Provides security review analysis based on OWASP guidelines.
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., "@cli-bridge Generate a social card image using GPT lane"
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.
cli-bridge
A Model Context Protocol server that lets the AI assistant
you're talking to consult the other AI CLIs installed on your machine — Claude Code, Codex,
Gemini, Mistral, opencode, Ollama, Apple fm, … Each lane spawns the official CLI as a
subprocess: no API keys, no token extraction, read-only by default.
Dependencies: the Python stdlib and mcp (1.x or 2.x). No daemon.
What it does
ask_gemini(task="find the bug across ./src", cwd="path/to/repo") # one lane (1M-token context)
ask_apple(task="what's wrong in this UI?", images=["shot.png"]) # vision, on-device, $0
ask_all(task="…") # every free lane in parallel + disagreement score
ask_cascade(task="…") # cheapest→strongest, skips cooled-down lanes
ask_best(task="…", mode="deep") # router picks; rate_lane teaches it
ask_build(lane="opencode", task="add retry with backoff") # build in a throwaway worktree → diff
review_diff(base="origin/main", focus="security") # multi-model review, severity-ranked
debate(task="which migration strategy?", vote="borda") # N blind answers, peer-ranked
workflow(preset="converge", task="is this migration safe?") # author → blind arbiter → cross-family peers
git_text(kind="commit") # Conventional Commit from the staged diffEvery ask_<lane> returns a thread id; reuse it (even on another lane) for a multi-model
conversation that survives /compact. conversations lists or replays threads.
Tools
15 fixed tools + one ask_<lane> per installed CLI:
Consult:
ask_<lane>,ask_all,ask_cascade,ask_best,conversations,list_modelsBuild:
ask_build(mode=isolated→ diff,mode=direct→ zone-guarded writes; withmode=direct,async=true→ steerable viajob)Review:
review_diff(focus=code|security),debate(vote=judge|borda),workflow(presets:refine_plan,map_review,research_verify,fanout_compare,converge,premortem,test_plan,challenge),git_text(kind=commit|pr)Operate:
job(action=status|result|cancel|list|tail|steer),rate_lane,set_lane_cost,doctor,setup
CLI_BRIDGE_TOOLS=all adds batch_run (journaled fan-out) and reset_lane_state;
CLI_BRIDGE_TOOLS=default,batch_run extends the default; a plain comma list is exactly those.
Usage and lane health are MCP resources (cli-bridge://usage-summary, cli-bridge://lane-stats).
Full reference: docs/TOOLS.md.
There is also a human CLI, cli-bridge doctor|ask|ask-all|ask-best|build|review-diff|security-review|test-plan|premortem|stats|usage|jobs|set-cost (--json where it makes sense). cli-bridge build <lane> "<task>" prints the worktree diff; --apply lands it as unstaged changes.
Related MCP server: cli2mcp
Writing code safely
isolated(default): the delegate edits a throwaway git worktree and you get a diff. Your tree is untouched.direct: writes real files, but only inside thezoneyou declare, behind a per-zone lock with a post-turn zone-violation check; undo is zone-scoped.async=truemakes it steerable (job action=tail|steer) with an executable Definition-of-Done (dod_cmd).
CLI_BRIDGE_VERIFY_PLAN_READONLY=1 flags (never reverts) a read-only delegate that wrote files
anyway. Re-entry is depth-capped (CLI_BRIDGE_MAX_DEPTH, default 1). Delegates run in the
caller's cwd, else CLI_BRIDGE_DEFAULT_CWD, else the host's MCP workspace root.
Install
Prerequisites: Python 3.12+, uv, and at least one AI CLI installed and logged in.
uvx --from cli-bridge-mcp cli-bridge doctor # what cli-bridge can see (--deep probes each lane)Wire it into your host:
Claude Code:
claude mcp add cli-bridge -- uvx cli-bridge-mcp(or the plugin:claude plugin marketplace add JoaoBerne/cli-bridge-mcp && claude plugin install cli-bridge@cli-bridge-mcp).Any other MCP host (Codex, Cursor, VS Code, Zed, Claude Desktop, …):
{ "mcpServers": { "cli-bridge": { "command": "uvx", "args": ["cli-bridge-mcp"] } } }Per-host config paths:
docs/HOSTS.md. Full example with env vars:examples/mcp.example.json. GUI hosts launch servers with a minimal PATH; cli-bridge also searches the usual install dirs, or point a lane at its binary withCLI_BRIDGE_<LANE>_BIN=/full/path.
Restart the host, then ask it to consult a lane ("ask gemini to read ./src and find the bug").
cli-bridge-mcp is the server entry point; cli-bridge is the human CLI.
Configuration
Everything is env (set in the MCP server entry) or ~/.config/cli-bridge/config.json (env wins).
The knobs that matter:
CLI_BRIDGE_PROFILE=balanced # saver = free-only fan-out · balanced = paid when asked · max = best
CLI_BRIDGE_<LANE>_COST=free|limited|paid
CLI_BRIDGE_<LANE>_ENABLED=false # hide a lane
CLI_BRIDGE_<LANE>_MODEL=<model-id>
CLI_BRIDGE_<LANE>_DAILY_LIMIT=<runs/day> # enforced at spawn
CLI_BRIDGE_<LANE>_CREDITS_PER_1K=<credits> # makes CLI_BRIDGE_DAILY_CREDIT_CAP enforceable
CLI_BRIDGE_<LANE>_MIN_INTERVAL_S=2 # anti-burst pacing for a rate-limited free tier
CLI_BRIDGE_TERSE=off|lite|full|ultra
CLI_BRIDGE_GUARD=off|warn|strict # injection guard on delegate output
CLI_BRIDGE_CACHE_TTL_S=0 # >0 enables the response cache
CLI_BRIDGE_TRACE_FOOTER=off # hide the JSON trace footer in reports
CLI_BRIDGE_TOOLS=all # tool surface (see above)doctor --deep (or doctor(deep=true)) live-checks every free lane, its CLI version and its
model list, and reports what changed since the previous deep probe: run it weekly and you learn
about a renamed flag or a new model before a delegation fails.
set_lane_cost (or cli-bridge set-cost) records what a lane costs you, persisted to the
config file. Cost tiers are sourced defaults, never read from your account
(docs/COSTS.md); the full spend model is in docs/BUDGET.md.
Lanes
Built-in: Claude Code, Codex (gpt), Gemini (+ Antigravity agy), Mistral (Vibe), opencode,
Ollama (local, $0), Apple Foundation Models (fm, on-device, $0), Qwen Code, Copilot, Cursor,
Grok, and Apple PCC (hidden until APPLE_FM_SERVE_URL is set — it talks to a fm serve you
start from Terminal yourself; see examples/apple-fm-serve.lane.json).
images=[…] works on the vision lanes (apple, ollama, opencode, gpt, gemini); whether the image is
actually read depends on the model behind the lane.
Other CLIs are a few lines of JSON via CLI_BRIDGE_LANES_FILE:
examples/local-runtime.lane.json (LM Studio, MLX, llama.cpp;
runtime table in examples/local-first-host.md),
examples/community-lanes.json (Aider, Goose, Plandex, Amp,
Crush, Amazon Q, Droid), and any OpenAI-compatible endpoint via curl or the bundled
cli-bridge-openai bridge (examples/openai-compatible.lane.json).
Known limitations
No token or key extraction, but non-interactive use of a vendor CLI isn't formally sanctioned everywhere.
Async jobs are in-process: a server restart marks running jobs
interrupted.batch_run/workflowjournal each task and resume viaresume_id.The injection guard is heuristic. Treat delegate output as data.
Token/credit figures are estimates (chars/4 × your
CREDITS_PER_1K).Experimental lanes (
qwen,copilot,grok, community,images=):doctor --deepchecks each CLI's--helpon your machine.
Development
uv venv && uv pip install -e . pytest pytest-asyncio ruff
pytest -q # no real CLI or network needed
ruff check src/ tests/Eval harness (deterministic scorer, outside the package): benchmarks/.
History: CHANGELOG.md. Layout and rules: AGENTS.md, docs/ARCHITECTURE.md.
License
Apache 2.0
Available Tools
6 toolsdoctorARead-only
Health check: which CLIs are installed, which is the host, paid lanes, defaults, current cost profile. Pass deep=true to also probe each lane with a tiny live call (checks auth/quota — uses a bit of free quota; skips paid lanes).
Inputs: deep.
lane_statsARead-only
Per-lane health: total runs, failures, consecutive failures/timeouts, and any active cooldown (a lane in cooldown is skipped by ask_all until it clears).
Inputs: no named parameters.
reset_lane_stateA
Clear a lane's cooldown + failure counters (e.g. after you re-logged in or your quota reset). Pass the lane key, e.g. 'gemini'.
Inputs: lane (required).
setupARead-only
Show the cost-profile choice (saver/balanced/max) to walk the user through configuring how cli-bridge spends paid credits/quota. Call this on first use if the profile isn't set, ASK the user, then tell them how to set it.
Inputs: no named parameters.
usage_budgetARead-only
Per-lane runs since UTC midnight vs an optional CLI_BRIDGE__DAILY_LIMIT (ENFORCED at spawn once reached), plus estimated tokens/credits spent today. Estimates only.
Inputs: no named parameters.
usage_reportARead-only
Local usage stats (this machine only): total runs, per-lane counts/success/avg latency, ESTIMATED tokens (chars/4) and credits (if CLI_BRIDGE__CREDITS_PER_1K is set), and recent calls. All token/credit figures are estimates, never exact.
Inputs: since, output_format.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Tools are mostly distinct: doctor focuses on overall health and auth, lane_stats on per-lane health and cooldowns, usage_report on local totals, usage_budget on daily limits, and reset_lane_state on clearing state. Some overlap exists between doctor and lane_stats, but descriptions clarify the boundaries.
Names mix single verbs (doctor, setup) with noun phrases (lane_stats, usage_report, usage_budget, reset_lane_state). The verb_noun pattern is not consistent across the set, though the names themselves are descriptive and readable.
Six tools is well-scoped for a CLI bridge management server, covering health, usage, budget, and state reset without redundancy or bloat.
The domain of monitoring and managing CLI lanes is reasonably covered: health checks, usage stats, daily budgets, and state reset are all present. A minor gap is the lack of a direct configuration tool (e.g., setting the cost profile), though setup guides the user through it.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseAqualityCmaintenanceAn MCP server that bridges multiple AI clients (Claude, Gemini, Codex, OpenCode) so they can call each other as tools.1103 npm77-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to call any CLI tool by scanning its help output and serving it as an MCP server.1GPL 3.0
- AlicenseBqualityFmaintenanceA universal MCP server that automatically discovers and registers CLI tools as AI-powered agents with persona configuration, enabling any CLI tool to be used as an MCP tool.41MIT
- AlicenseNot gradedqualityCmaintenanceUniversal MCP server that wraps any CLI tool, enabling AI assistants to run commands via natural language.1MIT