code-mcp
Enables Claude AI to run terminal commands, perform file operations, and manage git in a project directory via the Model Context Protocol.
README
Code-MCP: Terminal and Code Integration for Claude AI
██████╗ ██████╗ ██████╗ ███████╗ ███╗ ███╗ ██████╗██████╗
██╔════╝██╔═══██╗██╔══██╗██╔════╝ ████╗ ████║██╔════╝██╔══██╗
██║ ██║ ██║██║ ██║█████╗ ████─ ██╔████╔██║██║ ██████╔╝
██║ ██║ ██║██║ ██║██╔══╝ ██║╚██╔╝██║██║ ██╔═══╝
╚██████╗╚██████╔╝██████╔╝███████╗ ██║ ╚═╝ ██║╚██████╗██║
╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝
Code-MCP connects Claude AI to your development environment through the Model Context Protocol (MCP), enabling terminal commands and file operations through the AI interface.
Features
-
Terminal Access: Run shell commands in your project directory directly from Claude
-
File Operations: Create, read, update, and delete files and directories
-
Git Integration: Special handling for git commands with safety confirmations
-
Smart Editing: Enhanced editing capabilities for code files
-
Code Analysis: Advanced pattern matching and function-level operations
-
Productivity Tools: Operate on your codebase with natural language instructions
-
Remote Connectivity: Connect to remote code-mcp instances over SSH
Quick Installation
The following commands install the base version. See the Optional Features section for installing with additional capabilities.
macOS / Linux
# Install with a single command (includes uv installation if needed)
curl -LsSf https://raw.githubusercontent.com/54yyyu/code-mcp/main/install.sh | sh
Windows
# Download and run the installer
powershell -c "Invoke-WebRequest -Uri https://raw.githubusercontent.com/54yyyu/code-mcp/main/install.ps1 -OutFile install.ps1; .\install.ps1"
Manual Installation
# Install with pip
pip install git+https://github.com/54yyyu/code-mcp.git
# Or better, install with uv
uv pip install git+https://github.com/54yyyu/code-mcp.git
Optional Features
Code-MCP offers optional feature sets that you can choose to install based on your needs:
Remote Connectivity Support
# Install with remote connectivity support
pip install git+https://github.com/54yyyu/code-mcp.git@remote-edit
# Or with uv
uv pip install git+https://github.com/54yyyu/code-mcp.git@remote-edit
# One-line installer
curl -LsSf https://raw.githubusercontent.com/54yyyu/code-mcp/remote-edit/install.sh | sh
Jupyter Notebook Support
# Install with Jupyter notebook support
pip install git+https://github.com/54yyyu/code-mcp.git@jupyter
# Or with uv
uv pip install git+https://github.com/54yyyu/code-mcp.git@jupyter
# One-line installer
curl -LsSf https://raw.githubusercontent.com/54yyyu/code-mcp/jupyter/install.sh | sh
Combining Features
To install both Remote Connectivity and Jupyter Notebook support, you can clone the repository and choose which features to include:
# Clone the repository
git clone https://github.com/54yyyu/code-mcp.git
cd code-mcp
# Create a custom branch with both features
git checkout main
git merge remote-edit --no-commit
git merge jupyter --no-commit
git commit -m "Custom installation with both remote and jupyter features"
# Install from your custom branch
pip install -e .
For Developers
If you're developing Code-MCP, clone the repository and install in development mode:
# Clone the repository
git clone https://github.com/54yyyu/code-mcp.git
cd code-mcp
# Install in development mode with pip
pip install -e .
# Or with uv (recommended)
uv pip install -e .
Usage
Claude Desktop Integration
-
Automatic setup:
# With a specific project path code-mcp-setup /path/to/your/project # Or run without arguments to use the current directory code-mcp-setup -
Or manually edit Claude Desktop configuration:
- Go to Claude > Settings > Developer > Edit Config
- Add the following to your
claude_desktop_config.json:
{
"mcpServers": {
"code": {
"command": "code-mcp",
"args": [
"/path/to/your/project"
]
}
}
}
- Save the file and restart Claude
Updating Existing Configurations
If you previously installed code-mcp but it requires an absolute path in your configuration,
you can use the setup helper with the --fix-path flag to update your configuration:
code-mcp-setup --fix-path
This will find your Claude Desktop configuration and update the command to use just code-mcp
instead of the full path, allowing it to work as long as code-mcp is in your PATH.
Note: All new installations automatically use the PATH-based approach.
Remote Connectivity
You can connect Claude Desktop to a code-mcp instance running on a remote server.
Prerequisites:
- SSH access to the remote server
- Python 3.10+ on both local and remote machines
The setup script will automatically check if code-mcp is installed on the remote server and install it if needed.
One-line installation
# Install and set up remote connection with one command
curl -sSL https://raw.githubusercontent.com/54yyyu/code-mcp/remote-edit/remote-install.sh | bash -s -- --remote-host user@hostname
# With additional options
curl -sSL https://raw.githubusercontent.com/54yyyu/code-mcp/remote-edit/remote-install.sh | bash -s -- \
--remote-host user@hostname \
--remote-project-path /path/to/project \
--local-port 3000 \
--remote-port 5000 \
--ssh-key ~/.ssh/id_ed25519
This installs code-mcp locally if needed, configures remote connection, and sets up Claude Desktop.
# Set up a remote connection (with default options)
code-mcp-remote --remote-host user@example.com --remote-project-path /path/to/remote/project
# Set up with custom port configuration
code-mcp-remote --remote-host user@example.com \
--remote-project-path /path/to/remote/project \
--local-port 3000 \
--remote-port 5000
# Use a specific SSH key
code-mcp-remote --remote-host user@example.com \
--remote-project-path /path/to/remote/project \
--ssh-key ~/.ssh/id_ed25519
The remote setup:
- Checks if code-mcp is installed on the remote server and installs it if needed
- Uploads the bridge server script to the remote server
- Starts the bridge server on the remote machine
- Sets up an SSH tunnel to securely communicate with the remote server
- Configures Claude Desktop to use the remote connection
This allows you to work with codebases on remote servers, including cloud VMs and containers. When you're done, press Ctrl+C to terminate the SSH tunnel and clean up the configuration.
Features
Terminal Operations
- Execute terminal commands with
run_command() - Perform git operations with
git_operation()
File Operations
- Read files with
read_file() - Edit files with
edit_file()andsmart_edit() - Create and delete directories with
create_directory()anddelete_path() - List directory contents with
list_directory()
Advanced Code Editing
- Flexible pattern matching with whitespace normalization
- Function-level editing with automatic indentation handling
- Batch operations across multiple files with
edit_block() - Support for search/replace blocks and unified diff formats
Examples
Ask Claude:
- "List all the files in the current directory"
- "Show me the content of the README.md file"
- "Create a new file called example.py with a simple hello world program"
- "Run git status and show me what files have changed"
- "Make these changes to main.py: replace X with Y"
- "Update the process_data function in data_utils.py to handle null values"
Safety Features
- Confirmation required for destructive operations (delete, overwrite)
- Path safety to prevent operations outside project directory
- Special confirmation for potentially dangerous git commands
Requirements
- Python 3.10 or newer
- Claude Desktop or API access
- Git (optional, for git operations)
License
This project is licensed under the MIT License - see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。