Skip to main content
Glama

Bridge Anthropic Claude Code CLI to any MCP client

English | 한국어

npm · GitHub · Issues

npm version license


Overview

An MCP (Model Context Protocol) server that wraps Anthropic Claude Code CLI as tools. Lets MCP clients like Claude Desktop, Cursor, Windsurf, and Claude Code itself invoke headless Claude Code sessions.

Forked from @nayagamez/codex-cli-mcp. Same architecture (stdio MCP, stream-json parser, idle timeout, progress notifications) — adapted for claude CLI semantics.

Related MCP server: claude-code-mcp

Prerequisites

1. Install Claude Code CLI

The recommended method is the native installer (Node.js not required, auto-updates):

# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash

# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Other options: brew install --cask claude-code · winget install Anthropic.ClaudeCode · apt/dnf/apk via downloads.claude.ai · npm install -g @anthropic-ai/claude-code (advanced).

Windows native install requires Git for Windows. See Claude Code setup docs for details.

2. Authenticate

Run claude and follow the browser prompt to sign in. Requires a Pro, Max, Team, Enterprise, or API plan.

For headless / CI:

export ANTHROPIC_API_KEY="sk-ant-..."

See Authentication docs.

3. Node.js (npm) installed

The Setup snippets below invoke this server with npx -y (ships with npm). Verify Node ≥ 18:

node --version
npm --version

If missing, install Node.js LTS from nodejs.org.

If you'd rather use Bun's bunx (avoids Windows .cmd shim issues), see the installation guide §5.7 for the alternative TOML block.

Tools

claude

Start a new Claude Code session.

Parameter

Type

Required

Description

prompt

string

Yes

The prompt to send

model

string

No

Model id or alias (sonnet, opus, haiku, or full id)

effort

enum

No

low, medium, high, xhigh, max

permissionMode

enum

No

default, plan, acceptEdits, auto, dontAsk, bypassPermissions (default: bypassPermissions)

cwd

string

No

Working directory

addDirs

string[]

No

Additional read/write directories (--add-dir)

allowedTools

string[]

No

e.g. ["Bash(git *)", "Edit"]

disallowedTools

string[]

No

Tools that may not be used

appendSystemPrompt

string

No

Text appended to default system prompt

mcpConfig

string[]

No

MCP server config files or JSON strings

maxTurns

number

No

Limit agentic turns (headless safety stop)

bare

boolean

No

--bare mode (skip hooks/skills/plugins/MCP). Requires API key

timeout

number

No

Idle timeout in ms (default: 600000)

The response includes a Session ID that can be passed to claude-reply.

claude-reply

Continue an existing Claude Code session.

Parameter

Type

Required

Description

prompt

string

Yes

Follow-up prompt

sessionId

string

Yes

Session ID from a previous claude call

model, effort, permissionMode, allowedTools, disallowedTools, appendSystemPrompt, mcpConfig, maxTurns, bare, timeout

No

Same as claude

forkSession

boolean

No

Create a new session ID instead of reusing the original (--fork-session)

No cwd parameter. Sessions are tied to the directory they were started in (Claude Code issue #5768). Run from the original cwd.

⚠️ Known Issues & Warnings

  1. bypassPermissions is the default — Matches codex --full-auto parity. Bypass mode has known instability (issue #39523) where protected directory writes still prompt and the mode can reset mid-session. For sensitive workspaces use permissionMode: "acceptEdits" or "auto".

  2. Resume requires the original cwd — Sessions cannot be moved across directories. Same-cwd execution is the user's responsibility (issue #5768).

  3. Windows native CLI bug — Claude Code on Windows native may exit silently with no output, hang, or report Query closed before response received (issue #50616). Recommended fallback: WSL.

  4. bare: true breaks OAuth--bare skips OAuth and keychain reads. Authentication must come from ANTHROPIC_API_KEY or apiKeyHelper. Pro/Max OAuth users must keep bare: false (the default).

  5. --bare is the future default for -p — Anthropic has stated --bare will become the default for -p in a future release (headless docs). v0.1 explicitly defaults to bare: false for OAuth compatibility; behavior may need to be revisited.

Setup

The primary use case is OpenAI Codex CLI delegating work to Claude Code as a sub-agent. Cursor and Windsurf are also supported. Calling this server from Claude Code itself is not useful (Claude calling Claude).

For Humans

Copy the prompt below and paste it into your LLM agent (Codex, Cursor, Windsurf, etc.) — it will install and configure everything automatically:

Install and configure @nayagamez/claude-cli-mcp by following: https://raw.githubusercontent.com/nayagamez/claude-cli-mcp/main/docs/guide/installation.md

Or set it up manually — see Manual Setup below.

For LLM Agents

curl -s https://raw.githubusercontent.com/nayagamez/claude-cli-mcp/main/docs/guide/installation.md

Manual Setup

Examples below use npx -y as the default runner. If you'd rather use Bun's bunx, see installation guide §5.7.

Codex CLI

Edit ~/.codex/config.toml (global) or .codex/config.toml (project-scoped, trusted projects only):

[mcp_servers.claude-cli-mcp]
command = "npx"
args = ["-y", "@nayagamez/claude-cli-mcp"]

# Codex defaults (10s / 60s) are too short for npx cold install +
# Claude Code first response. Do not omit these.
startup_timeout_sec = 30
tool_timeout_sec = 600

Restart Codex to load the server. See installation guide for project-scope and trusted-project notes.

Cursor / Windsurf

Add to the appropriate MCP config (.cursor/mcp.json, ~/.cursor/mcp.json, .windsurf/mcp.json, etc.):

{
  "mcpServers": {
    "claude-cli-mcp": {
      "command": "npx",
      "args": ["-y", "@nayagamez/claude-cli-mcp"]
    }
  }
}

Progress Notifications

The server sends MCP progress notifications in real-time as Claude processes your request:

  • [5s] Session started (<id>, model: claude-sonnet-4-6) — init received

  • [12s] Tool use: Bash — agent invoked a tool

  • [18s] Message: Refactoring the auth module... — assistant text

  • [24s] Retry 2/3 in 1000ms (rate_limit)system/api_retry event

  • [25s] Result: success (24230ms, $0.0142) — final result

Idle-based Timeout

Timeout is idle-based: the timer resets on every event. Long-running tasks with continuous activity never time out; truly stuck processes are killed after the configured idle period.

  • Default: 10 minutes

  • Override per-call via timeout, or globally via CLAUDE_TIMEOUT_MS

Environment Variables

Variable

Default

Description

CLAUDE_CLI_PATH

claude

Path to the Claude Code CLI binary

CLAUDE_TIMEOUT_MS

600000 (10 min)

Idle timeout for child Claude process

CLAUDE_MCP_DEBUG

(unset)

Set to enable debug logging to stderr

The server automatically scrubs the following env vars from the spawned child to prevent parent Claude Code state from leaking into headless invocations:

  • CLAUDECODE, CLAUDE_CODE_SIMPLE (officially documented parent-detection signals)

  • CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_SSE_PORT, CLAUDE_PROJECT_DIR (observed contributors to parent stop-hook injection)

ANTHROPIC_API_KEY, apiKeyHelper, and Bedrock/Vertex/Foundry credentials are preserved.

How It Works

MCP Client  →  Tool Call (claude / claude-reply)
            →  Spawn `claude -p --output-format stream-json --verbose ...`
            →  Pipe a stream-json user envelope into stdin
            →  Parse JSONL events from stdout
            →  Send progress notifications on each event (idle timer resets)
            →  Return aggregated result + session id
  1. MCP client sends claude or claude-reply tool call

  2. Server spawns claude with -p, --output-format stream-json, --input-format stream-json, --verbose, plus user-specified flags

  3. Prompt is delivered as a single-line user envelope on stdin (avoids Windows 8191-char cmd.exe limit)

  4. stream-json events are parsed in real time (system/init, system/api_retry, system/plugin_install, assistant, user, result, rate_limit_event)

  5. Progress notifications are sent on every event; idle timer resets

  6. Final result includes session id, messages, tool uses, structured error, usage, and cost

License

MIT

Available Tools

2 tools
claudeA

Run a Claude Code CLI session. Executes claude -p --output-format stream-json as a subprocess and returns the result.

Use this tool to start a new coding task with Claude Code. The response includes a Session ID that can be used with the claude-reply tool to continue the conversation.

WARNING: defaults to permission mode bypassPermissions (parity with codex --full-auto). Use a safer mode (e.g. acceptEdits or auto) for sensitive workspaces.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesThe prompt to send to Claude
modelNoModel id or alias (e.g. "sonnet", "opus", "claude-sonnet-4-6"). Do NOT set this unless the user explicitly requests a specific model.
effortNoReasoning effort. Auto-select based on task complexity: low/medium for simple tasks, high for moderate, xhigh/max for complex multi-file work. Do NOT set if the user has not asked for a specific level.
permissionModeNoPermission mode. Defaults to "bypassPermissions" (parity with codex --full-auto). Use "acceptEdits" or "auto" for safer behavior.
cwdNoWorking directory for the Claude session
addDirsNoAdditional directories Claude can read/edit (--add-dir).
allowedToolsNoTools Claude may use without permission prompt (e.g. ["Bash(git *)", "Edit"]). See Claude permission rule syntax.
disallowedToolsNoTools Claude must not use.
appendSystemPromptNoText appended to the default system prompt.
mcpConfigNoMCP server config files or JSON strings (--mcp-config, repeatable).
maxTurnsNoLimit the number of agentic turns (--max-turns). Headless safety stop.
bareNoRun with --bare (skip hooks/skills/plugins/MCP/CLAUDE.md). NOTE: requires ANTHROPIC_API_KEY or apiKeyHelper — Pro/Max OAuth users will fail to authenticate.
timeoutNoIdle timeout in milliseconds (default: 600000 = 10 min). Resets on every event.

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses execution as subprocess, output format, session ID generation, and default permission mode with safety warning. However, lacks details on idempotency, error handling, or side effects beyond the permission mode note.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Very concise: three short paragraphs front-loading the main purpose, continuation usage, and a critical warning. No unnecessary content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has 13 parameters and no output schema, but description only covers high-level behavior and permission mode. Missing details on return value structure, error behavior, and parameter interactions. Could be more complete given complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with detailed parameter descriptions. The tool description adds no extra meaning beyond what schema already provides, so baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it runs a Claude Code CLI session and starts a new coding task. It distinguishes from the sibling tool claude-reply by noting that session ID can be used to continue the conversation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says to use this tool to start a new coding task and points to claude-reply for continuation. Also includes a warning about permission mode defaults, guiding safer usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

claude-replyA

Continue a Claude Code CLI conversation by providing the session ID from a previous claude call and a follow-up prompt.

Uses claude --resume <session-id> to load the previous session and continue.

NOTE: Sessions are tied to the directory they were started in (Claude Code issue #5768). The MCP server cannot change the resumed session's working directory — make sure the host process runs from the original cwd, otherwise the session may not be found.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesThe follow-up prompt to send to Claude
sessionIdYesThe session ID from a previous claude tool call
modelNoModel id or alias. Do NOT set unless the user explicitly requests one.
effortNoReasoning effort. Auto-select based on task complexity.
permissionModeNoPermission mode. Whether resume honors mid-session changes is experimental — see plan §6.5.
allowedToolsNoTools Claude may use without permission prompt (e.g. ["Bash(git *)", "Edit"]).
disallowedToolsNoTools Claude must not use.
appendSystemPromptNoText appended to the default system prompt.
mcpConfigNoMCP server config files or JSON strings (--mcp-config, repeatable).
maxTurnsNoLimit the number of agentic turns (--max-turns).
forkSessionNoCreate a new session ID instead of reusing the original (--fork-session).
bareNoRun with --bare. Requires ANTHROPIC_API_KEY or apiKeyHelper.
timeoutNoIdle timeout in milliseconds (default: 600000 = 10 min).

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses the underlying mechanism (claude --resume) and a known issue (directory dependency). However, lacks details on error handling, return behavior, or consequences of invalid session IDs. Relies on schema for parameter descriptions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short paragraphs with no redundant information. First sentence clearly states the tool's purpose, followed by mechanism and a necessary caveat. Efficient and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 13 parameters and no output schema, the description provides essential context on usage and a critical limitation. Could include more on return values or error states, but the caveat about directory binding is valuable for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema describes all 13 parameters with 100% coverage, so baseline is 3. The description adds context about session ID directory binding but does not significantly enhance parameter understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it continues a Claude Code CLI conversation using a session ID and follow-up prompt. Distinguishes itself from the sibling 'claude' tool by specifying resumption rather than initiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides context on when to use (follow-up conversations) and includes a critical caveat about directory binding. Could explicitly exclude use for new conversations, but the distinction from 'claude' is implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.7
    • First observedclaude
    • First observedclaude-reply

TDQS

A4.2/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: 'claude' starts a new Claude Code CLI session, while 'claude-reply' continues an existing session using a session ID. There is no overlap or ambiguity.

Naming Consistency5/5

Both tool names use a consistent lowercase-with-hyphen pattern ('claude' and 'claude-reply'), where the first is a base command and the second adds a modifier. The naming is predictable and clear.

Tool Count4/5

With only two tools, the set is minimal but sufficient for starting and continuing Claude Code sessions. The count is slightly low but reasonable given the focused scope of the server.

Completeness3/5

The server covers the essential actions (starting and continuing sessions) but lacks tools for explicitly ending sessions, listing active sessions, or changing session parameters. The absence of session management creates a notable gap.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    Local MCP server that wraps the headless Claude Code CLI as MCP tools, providing stateless access to Claude's coding capabilities through prompt-based interactions. It enables users to execute Claude Code commands with various prompt formats and structured outputs directly from MCP clients.
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Wraps Claude Code as tools for MCP clients, enabling autonomous coding tasks via a 4-tool lifecycle with session management, async polling, and permission controls.
    4
    57
    20
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server that wraps AI CLI tools — Claude Code, Antigravity CLI, and Codex CLI — so any MCP client can call them as tools.
    453
    9
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nayagamez/claude-cli-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server