Claude Code MCP server

Enables Claude to execute code-related tasks through direct tools for code understanding, modification, command execution, and file operations with proper security controls.
Back to servers
Setup instructions
Provider
SDGLBL
Release date
Mar 18, 2025
Language
Python
Stats
242 stars

The MCP Claude Code server implements Claude Code-like functionality through the Model Context Protocol (MCP), enabling Claude to execute instructions for modifying and improving project files. This implementation works seamlessly with MCP clients like Claude Desktop, allowing for code analysis, modifications, and project management.

Features

  • Code Understanding: Analyze and understand codebases through file access and pattern searching
  • Code Modification: Make targeted edits to files with proper permission handling
  • Enhanced Command Execution: Run commands and scripts with improved error handling
  • File Operations: Manage files with proper security controls
  • Code Discovery: Find relevant files and code patterns across your project
  • Project Analysis: Understand project structure, dependencies, and frameworks

Installation

You can run the MCP Claude Code server without installation using uvx:

uvx run mcp-claude-code

Configuration

Setting Up Claude Desktop

To configure Claude Desktop to use this server, add the following to your Claude Desktop configuration file:

{
  "mcpServers": {
    "claude-code": {
      "command": "uvx",
      "args": [
        "--from",
        "mcp-claude-code",
        "claudecode",
        "--allow-path",
        "/path/to/your/project"
      ]
    }
  }
}

Be sure to replace /path/to/your/project with the actual path to your project directory.

Advanced Configuration Options

For more customization, you can use additional options:

{
  "mcpServers": {
    "claude-code": {
      "command": "uvx",
      "args": [
        "--from",
        "mcp-claude-code",
        "claudecode",
        "--allow-path",
        "/path/to/project",
        "--name",
        "custom-claude-code",
        "--transport",
        "stdio"
      ]
    }
  }
}

Optimizing Claude Desktop System Prompt

For the best experience, add the system prompt to your Claude Desktop client:

  1. Locate the system prompt file in the repository at doc/system_prompt
  2. Open your Claude Desktop client settings
  3. Navigate to the system prompt configuration section
  4. Copy the contents of system_prompt into your project instructions
  5. Replace {{project_path}} with the absolute path to your project

This system prompt provides Claude with:

  • A structured workflow for analyzing and modifying code
  • Best practices for project exploration
  • Guidelines for development and refactoring
  • Special formatting instructions for mathematical content

Available Tools

The server implements several tools to help Claude interact with your codebase:

File Operations

  • read_files: Read files with automatic encoding detection
  • write_file: Create or overwrite files (requires permission)
  • edit_file: Make line-based edits to text files (requires permission)
  • get_file_info: Get metadata about files or directories
  • directory_tree: Get a recursive tree view of directories

Search and Analysis

  • search_content: Search for patterns in file contents
  • content_replace: Replace patterns in file contents (requires permission)
  • project_analyze_tool: Analyze project structure and dependencies

Execution

  • run_command: Execute shell commands (requires permission)
  • run_script: Execute scripts with specified interpreters (requires permission)
  • script_tool: Execute scripts in specific programming languages (requires permission)

Security Features

The implementation includes several security measures:

  • Permission prompts for file modifications and command execution
  • Restricted access to specified directories only
  • Input validation and sanitization
  • Proper error handling and reporting

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "claude-code" '{"command":"uvx","args":["--from","mcp-claude-code","claudecode","--allow-path","/path/to/your/project"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "claude-code": {
            "command": "uvx",
            "args": [
                "--from",
                "mcp-claude-code",
                "claudecode",
                "--allow-path",
                "/path/to/your/project"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "claude-code": {
            "command": "uvx",
            "args": [
                "--from",
                "mcp-claude-code",
                "claudecode",
                "--allow-path",
                "/path/to/your/project"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later