Home / MCP / Claude Code MCP Server

Claude Code MCP Server

MCP server that interfaces Claude Code CLI to expose code-related tools via MCP

typescript
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "claude_code_mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@kunihiros/claude-code-mcp"
            ],
            "env": {
                "CLAUDE_BIN": "/path/to/your/claude/executable",
                "LOG_LEVEL": "info"
            }
        }
    }
}

The Claude Code MCP Server lets you expose Claude Code’s code-related capabilities as an MCP toolset. It runs locally and communicates with Claude Code through the Claude CLI, handling requests, encoding input, executing the appropriate Claude Code commands, and returning results in JSON. This makes it easy to integrate Claude Code into client tools and automation via MCP clients.

How to use

Install and run the server using an MCP-compatible client or host. You provide the path to the Claude CLI executable and an optional log level. Start the server through an MCP host that can launch local stdio servers.

Typical usage patterns include starting the server via an MCP host with an inline config, or running it directly with npx for quick experimentation. Once running, you can send tool requests such as explain_code, review_code, fix_code, edit_code, test_code, simulate_command, and your_own_query. The server handles input encoding, builds the appropriate Claude Code CLI command, executes it, and returns the output in JSON.

How to install

Prerequisites you need before starting: Node.js (version 18 or newer is recommended, tested with v22.14.0) and npm (or yarn). You also need Claude Code command installed and authenticated.

Choose one of these installation methods to run the MCP server.

Option 1: Using npx (recommended for quick use) You can run the server directly without installation using npx: npx @kunihiros/claude-code-mcp

Option 2: Global installation Install the package globally: npm install -g claude-code-mcp Then run it as a command: claude-code-mcp

Option 3: Local installation (for development) Clone the project, install dependencies, build, and run the built script: git clone https://github.com/KunihiroS/claude-code-mcp.git cd claude-code-mcp/claude-code-server npm install npm run build Then start with: node build/index.js

Configuration and runtime details

Environment variables control where Claude CLI is located and the log verbosity. Define one of the following configurations to set variables.

# .env or ~/.claude-code-mcp.env
CLAUDE_BIN=/path/to/your/claude/executable  # REQUIRED: Path to Claude CLI executable
LOG_LEVEL=info                             # Optional: debug, info, warn, error

Available tools

explain_code

Provides a detailed explanation of the given code.

review_code

Reviews the given code for quality and potential issues.

fix_code

Fixes bugs or problems found in the code.

edit_code

Edits the code based on provided instructions.

test_code

Generates tests for the given code.

simulate_command

Simulates the execution of a given command.

your_own_query

Sends a custom query with context.