Skip to main content
Glama

mcp-claude-code

An MCP server that drives the Claude Code CLI in headless mode, so any MCP client (Claude Desktop, Antigravity, Cursor, another agent…) can delegate coding tasks to Claude Code, resume sessions, inspect context usage and read account limits.

Requirements

  • Node.js 18+

  • Claude Code installed and logged in (claude on PATH, or set CLAUDE_BIN)

Related MCP server: Claude Code Manager WAN

Install

git clone https://github.com/<owner>/mcp-claude-code.git
cd mcp-claude-code
npm install

Client configuration

{
  "mcpServers": {
    "claude-code": {
      "command": "node",
      "args": ["/path/to/mcp-claude-code/server.mjs"],
      "env": {
        "WORKSPACE_DIR": "/path/to/your/project"
      }
    }
  }
}

Tools

Tool

Arguments

Description

claude_run_task

prompt (required), sessionId, model (opus|sonnet|haiku|fable), effort (low…max), cwd, permissionMode (bypassPermissions|acceptEdits|plan|default), timeoutMs

Runs a task with claude -p --output-format stream-json. Starts a new session or resumes sessionId. Returns the final response, session ID, tools executed, token usage, cost and where it ran. 30 min hard timeout (configurable) plus a 5 min inactivity watchdog.

claude_session_status

sessionId (required), projectDir

Reads the session JSONL under ~/.claude/projects and reports context tokens, % of the 1M window, active model, turn counts and a near-limit flag.

claude_list_sessions

limit (default 10), cwd

Lists the most recent sessions with initial prompt, model and context usage. Optionally filtered by project directory.

claude_compact_session

sessionId (required), cwd

Sends /compact to a session and reports tokens before/after.

claude_account_limits

—

Live 5-hour and weekly quota (% used/remaining, reset times) captured from Claude Code rate_limit_events (cached 3 min), plus today's token consumption across all local sessions.

claude_configure

model, effort

Reads or updates the default model/effort used when claude_run_task omits them.

⚠️ permissionMode defaults to bypassPermissions (--dangerously-skip-permissions). Only point this server at workspaces where unattended command execution is acceptable, or pass a stricter mode.

Environment variables

See .env.example. All are optional.

Variable

Default

Purpose

WORKSPACE_DIR

server cwd

Default working directory for tasks

CLAUDE_BIN

auto-detected

Path to the claude CLI

CLAUDE_MCP_SETTINGS_FILE

~/.config/mcp-claude-code/settings.json

Persisted defaults from claude_configure

CLAUDE_MCP_QUOTA_FILE

~/.claude-live-quota.json

Quota telemetry cache

CLAUDE_MCP_LOCALE

es-AR

Locale for reset-time formatting

Optional remote SSH worker

By default every task runs locally. Set CLAUDE_REMOTE_SSH_HOST to run tasks on another machine over SSH instead:

Variable

Default

Purpose

CLAUDE_REMOTE_SSH_HOST

(unset → disabled)

SSH host or ~/.ssh/config alias (key-based login required)

CLAUDE_REMOTE_BIN

claude

Claude Code binary on the remote host

CLAUDE_REMOTE_WORKSPACE_DIR

local cwd

Working directory on the remote host

CLAUDE_REMOTE_SYNC_SESSIONS

1

rsync session JSONL files to/from the remote so --resume and the session tools keep working

CLAUDE_REMOTE_FORWARD_TOKEN

0

Forward the local CLAUDE_CODE_OAUTH_TOKEN over stdin (never on the command line)

FORCE_LOCAL_CLAUDE

0

1 forces local execution

If the SSH connection fails before any output (exit 255), the task is retried locally.

Development

npm run check   # node --check on every module
npm start       # run the stdio server

License

MIT

Available Tools

6 tools
claude_account_limitsA

Consulta la cuota y límites de la cuenta de Claude: límite móvil de 5 horas (% usado/restante), límite semanal (% usado/restante), créditos extra disponibles y el total de tokens consumidos hoy a través de todas las sesiones.

Inputs: no named parameters.

claude_compact_sessionB

Ejecuta el comando /compact en una sesión existente de Claude Code para reducir los tokens acumulados en la ventana de contexto y recuperar velocidad.

Inputs: sessionId (required), cwd.

claude_configureC

Consulta o actualiza el modelo y nivel de esfuerzo/thinking predeterminados para las tareas ejecutadas por Claude Code MCP.

Inputs: model, effort.

claude_list_sessionsA

Lista las sesiones de Claude Code registradas en la máquina, ordenadas por fecha reciente, indicando su prompt inicial, tokens en contexto y modelo.

Inputs: cwd, limit.

claude_run_taskB

Ejecuta una tarea, refactor, suite de tests o instrucción técnica usando el agente autónomo de Claude Code. Puede iniciar una sesión limpia o reanudar una sesión existente (pasando sessionId) con continuidad de contexto y ejecución headless de comandos.

Inputs: prompt (required), cwd, model, effort, +3 more.

claude_session_statusA

Consulta el estado de una sesión de Claude Code: porcentaje de la ventana de contexto usado (tope 1M de tokens), tokens acumulados, modelo activo, fecha de última modificación y alerta de límite.

Inputs: sessionId (required), projectDir.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool maps to a fairly distinct action (list, compact, account quota, configure, run, status), but claude_list_sessions and claude_session_status overlap since both report tokens and model, differing mainly in scope and detail level. claude_account_limits vs claude_session_status also both surface token/limit information, which could cause occasional misselection.

    Naming Consistency4/5

    All tools share a claude_ prefix and snake_case, which is highly predictable. Minor deviations exist: account_limits is noun-only and configure is verb-only, while the rest follow verb_noun (list_sessions, compact_session, run_task, session_status).

    Tool Count5/5

    Six tools is a well-scoped set for a Claude Code session manager: discovery, inspection, maintenance, configuration, quota check, and task execution. Each tool clearly earns its place with no filler.

    Completeness3/5

    Core lifecycle is covered (list, inspect, compact, run, configure, quota), but there is no way to read a session's actual transcript or task output, nor to delete/clean up or stop a running session. These gaps will force agents to work around missing read/cleanup operations when a task result needs inspecting.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP clients to spawn and control Codex CLI and Claude Code sessions on the host machine, with session management and filesystem access.
      4
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables ISLI agents and MCP clients to dispatch natural-language coding and terminal tasks to a locally-installed Claude Code CLI, supporting both one-shot execution and persistent sessions with workspace and security controls.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients such as Cursor to hand a bounded task to a scoped, non-interactive Claude Code session billed to a Claude subscription rather than Cursor model credits. Runs read-only by default, with optional file edits or Bash, plus budget, timeout, and session-resume controls.
      MIT