MCP Hub
Back to servers

claude-mcp-bridge

MCP server wrapping Claude Code CLI for query, review, search, structured output, sessions.

Registry
Stars
1
Updated
Apr 21, 2026

Quick Install

npx -y claude-mcp-bridge

claude-mcp-bridge

npm version npm downloads CI License: MIT Node.js TypeScript MCP

MCP server that wraps Claude Code CLI as a subprocess, exposing its capabilities as Model Context Protocol tools.

Works with any MCP client: Codex CLI, Gemini CLI, Cursor, Windsurf, VS Code, or any tool that speaks MCP.

Do you need this?

If you're in a terminal agent (Codex CLI, Gemini CLI) with shell access, call Claude Code CLI directly:

# Quick review of current diff
git diff origin/main...HEAD | claude -p --bare "Review this diff for bugs and security issues"

# Agentic review (Claude reads files, follows imports, checks tests)
claude -p --bare --allowed-tools "Read Grep Glob Bash(git diff:*,git log:*,git show:*)" \
  "Review the changes on this branch vs main"

# Analyze specific files
claude -p --bare --allowed-tools "Read" "Analyze src/utils/parse.ts for edge cases"

# With budget cap
claude -p --bare --max-budget-usd 0.50 "Is this retry logic sound?"

--bare skips hooks, memory, and plugins for clean subprocess use. --allowed-tools controls exactly what Claude can access. --max-budget-usd prevents runaway costs.

Use this MCP bridge instead when:

  • Your client has no shell access (Cursor, Windsurf, Claude Desktop, VS Code)
  • You need structured output with native --json-schema validation
  • You need session resume across calls (--resume SESSION_ID)
  • You need concurrency management and security hardening
  • You want cost metadata surfaced in MCP responses

Quick Start

npx claude-mcp-bridge

Prerequisites

  • Claude Code CLI installed and on PATH
  • Authentication (one of):
    • Subscription (default): claude login (uses your Pro/Max plan, no API credits needed)
    • API key: set ANTHROPIC_API_KEY + CLAUDE_BRIDGE_USE_API_KEY=1 (billed per use via console.anthropic.com)

Codex CLI

Add to ~/.codex/config.json:

{
  "mcpServers": {
    "claude-bridge": {
      "command": "npx",
      "args": ["-y", "claude-mcp-bridge"]
    }
  }
}

Gemini CLI

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "claude-bridge": {
      "command": "npx",
      "args": ["-y", "claude-mcp-bridge"]
    }
  }
}

Cursor / Windsurf / VS Code

Add to your MCP settings:

{
  "claude-bridge": {
    "command": "npx",
    "args": ["-y", "claude-mcp-bridge"],
    "env": {
      "ANTHROPIC_API_KEY": "sk-ant-...",
      "CLAUDE_BRIDGE_USE_API_KEY": "1"
    }
  }
}

Tools

ToolDescription
queryExecute prompts with file context, session resume, effort control, and budget caps. Supports text and images.
reviewAgentic code review. Claude explores the repo with Read, Grep, Glob, and git commands. Quick diff-only mode available.
searchWeb search via Claude CLI's WebSearch and WebFetch tools. Returns synthesized answers with sources.
structuredJSON Schema validated output via Claude CLI's native --json-schema.
pingHealth check with CLI version, auth method, capabilities, and model config.
listSessionsList active sessions with cumulative cost, turn count, and timestamps.

query

Execute a prompt with optional file context. Supports session resume via sessionId, effort control (low/medium/high/max), and budget caps (maxBudgetUsd). Images (.png, .jpg, .gif, .webp, .bmp) up to 5MB each are passed to Claude's Read tool.

Key parameters: prompt (required), files, model (default sonnet), sessionId, effort, maxBudgetUsd, workingDirectory, timeout (default 60s).

review

Two modes:

  • Agentic (default): Claude runs inside the repo with Read, Grep, Glob, and git commands. It diffs, reads files, follows imports, and checks tests. Timeout auto-scales from diff size.
  • Quick (quick: true): Diff-only review, no repo exploration. Faster and cheaper.

Key parameters: uncommitted (default true), base, focus, quick, model (default opus), effort (default high), maxBudgetUsd, workingDirectory, timeout.

search

Web search powered by Anthropic's WebSearch tool via Claude CLI. Returns synthesized answers with source URLs.

Key parameters: query (required), model (default sonnet), maxResponseLength, maxBudgetUsd, timeout (default 120s).

structured

Generate JSON conforming to a provided schema using Claude CLI's native --json-schema flag. Returns clean JSON in the first content block, metadata in a separate block so JSON parsing isn't broken.

Key parameters: prompt (required), schema (required, JSON string, max 20KB), files, model (default sonnet), sessionId, maxBudgetUsd, timeout (default 60s).

ping

No parameters. Returns CLI version, auth method (subscription/api-key/none), configured models, capabilities, and server version.

listSessions

No parameters. Returns active sessions with metadata: sessionId, model, createdAt, lastUsedAt, turnCount, totalCostUsd.

All tools attach execution metadata (_meta) with durationMs, model, sessionId, totalCostUsd, and token breakdowns. See DESIGN.md for details.

Configuration

Models

VariableDefaultDescription
CLAUDE_DEFAULT_MODELShared default for all tools
CLAUDE_QUERY_MODELsonnetDefault for query
CLAUDE_STRUCTURED_MODELsonnetDefault for structured
CLAUDE_SEARCH_MODELsonnetDefault for search
CLAUDE_REVIEW_MODELopusDefault for review
CLAUDE_FALLBACK_MODELhaikuFallback on quota exhaustion (none to disable)

Model resolution: explicit parameter > tool-specific env var > CLAUDE_DEFAULT_MODEL > built-in default.

Runtime

VariableDefaultDescription
CLAUDE_MAX_CONCURRENT3Max concurrent subprocess spawns
CLAUDE_CLI_PATHclaudePath to CLI binary
CLAUDE_MAX_BUDGET_USDGlobal cost cap in USD (per call)
ANTHROPIC_API_KEYAPI key (only forwarded when CLAUDE_BRIDGE_USE_API_KEY=1)
CLAUDE_BRIDGE_USE_API_KEYSet to 1 to forward ANTHROPIC_API_KEY to the subprocess (default: subscription auth)

Effort

VariableDefaultDescription
CLAUDE_REVIEW_EFFORThighDefault effort for review
CLAUDE_SEARCH_EFFORTmediumDefault effort for search
CLAUDE_QUERY_EFFORTDefault effort for query

Choosing a Claude Code MCP server

You need...Consider
Structured output, effort/budget control, session resume, cost metadataThis bridge
Multi-tool orchestration (read, grep, edit, bash as separate MCP tools)mcp-claude-code
Session continuity with async executionclaude-mcp
Maintained lightweight wrapper@kunihiros/claude-code-mcp
Native Claude Code MCP (built-in, no wrapper)claude mcp serve (docs)

Performance

Claude Code CLI has minimal startup overhead. Wall time is dominated by model inference and any agentic exploration.

ScenarioTypical time
Trivial prompt (sonnet)5-10s
Quick review, small diff15-30s
Agentic review (explores repo)30s to 10 min
Web search + synthesis15-30s

Cost metadata (totalCostUsd, token breakdowns) is returned in _meta on every response.

Bridge family

Three MCP servers, same architecture, different underlying CLIs. Each wraps a terminal agent as a subprocess and exposes it as MCP tools. Pick the one that matches your model provider, or run multiple for cross-model workflows.

claude-mcp-bridgegemini-mcp-bridgecodex-mcp-bridge
CLIClaude CodeGemini CLICodex CLI
ProviderAnthropicGoogleOpenAI
Toolsquery, review, search, structured, ping, listSessionsquery, review, search, structured, pingcodex, review, search, query, structured, ping, listSessions
Agentic reviewClaude explores repo with Read/Grep/Glob/gitGemini explores repo with file reads and gitCodex explores repo in full-auto mode
Structured outputNative --json-schema (no Ajv)Ajv validationAjv validation
Session resumeNative --resumeNot supportedSession IDs with multi-turn
Budget capsNative --max-budget-usdNot supportedNot supported
Effort control--effort low/medium/high/maxNot supportedNot supported
Cold start~1-2s~16s<100ms (inference dominates)
Authclaude login (default) or ANTHROPIC_API_KEY + opt-ingemini auth loginOPENAI_API_KEY
CostSubscription (default) or API credits (opt-in)Free tier availablePay-per-token
Concurrency3 (configurable)3 (configurable)3 (configurable)
Model fallbackAuto-retry with fallback modelNot supportedAuto-retry with fallback model

All three share: subprocess env isolation, path sandboxing, output redaction, FIFO concurrency queue, MCP tool annotations, _meta response metadata, progress heartbeats.

Development

npm install
npm run build        # Compile TypeScript
npm run dev          # Watch mode
npm test             # Run tests (vitest)
npm run lint         # ESLint
npm run typecheck    # tsc --noEmit
npm run smoke        # Smoke test against live CLI

Further reading

  • DESIGN.md - Architecture, sessions, cost tracking, response metadata, progress notifications
  • SECURITY.md - Environment isolation, path sandboxing, output redaction, tool sandboxing
  • CHANGELOG.md - Release history

License

MIT

Reviews

No reviews yet

Sign in to write a review