Discover how to run the Claude-code-mcp server effortlessly with npx for code explanation review and editing
ClaudeCode-MCP Server is an advanced MCP (Model Context Protocol) server specifically designed to facilitate integration between AI applications such as Claude Code and other tools. Utilizing Node.js and the MCP SDK, this server acts as a bridge, simplifying interaction with the Claude Code command-line interface through standardized protocols. It supports key functionalities like code explanation, review, debugging, editing, testing, and custom queries, enhancing AI workloads.
ClaudeCode-MCP Server leverages Model Context Protocol to ensure seamless communication between various AI applications and resources. It provides a robust framework for tools such as explain_code
, review_code
, fix_code
, edit_code
, test_code
, and your_own_query
. The server encodes natural language input using Base64 encoding, ensuring compatibility and improved stability. Additionally, it supports the integration of Claude Code CLI environments, enabling versatile usage across different operating systems.
The architecture of ClaudeCode-MCP Server is built to comply with the Model Context Protocol, facilitating easy onboarding for developers. The server uses Node.js for backend logic and MCP SDK for protocol handling. It receives JSON format requests via stdio from clients, encodes text inputs effectively, executes commands using Node.js's child_process.spawn
module, and returns results in JSON.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[ Claude Code CLI ]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
graph TD;
InputData--(Base64 Encode)-->EncodedData;
EncodedData--(JSON Requests)-->MCP-Server;
MCP-Server -->|Execute Command| ClaudeCode-CLI;
ClaudeCode-CLI--(Command Output)-->(Standard Output);
(Standard Output) --> (MCP-Server);
MCP-Server --(JSON Responses)-->EncodedData;
EncodedData--(Base64 Decode)-->OutputData;
To get started, ensure you have the following prerequisites:
You can use several methods to set up and run the server:
npx @kunihiros/claude-code-mcp
Install globally using npm or yarn:
npm install -g claude-code-mcp
# OR
yarn global add claude-code-mcp
Then run the server as a command:
claude-code-mcp
Clone and set up locally from the repository:
git clone https://github.com/KunihiroS/claude-code-mcp.git
cd claude-code-server
npm install
npm run build
node build/index.js
Regardless of your installation method, you need to configure environment variables. You can use one of the following approaches:
Using MCP Host Settings (Recommended for npx
):
# .env or ~/.claude-code-mcp.env
CLAUDE_BIN=/path/to/your/claude/executable # REQUIRED: Set the full path to your Claude CLI
LOG_LEVEL=info # Optional: Set log level (e.g., debug, info, warn, error)
Using a .env
file: Create a .env
in the project root and fill it with:
CLAUDE_BIN=/path/to/your/claude/executable # REQUIRED: Set the full path to your Claude CLI
LOG_LEVEL=info # Optional: Set log level (e.g., debug, info, warn, error)
Using a global config file: Create a ~/.claude-code-mcp.env
and fill it appropriately:
CLAUDE_BIN=/path/to/your/claude/executable # REQUIRED: Set the full path to your Claude CLI
LOG_LEVEL=info # Optional: Set log level (e.g., debug, info, warn, error)
For MCP Host settings configuration:
"claude-code-server": {
"command": "npx",
"args": [
"-y",
"@kunihiros/claude-code-mcp"
],
"env": {
"CLAUDE_BIN": "/path/to/your/claude/executable", // REQUIRED: Set the absolute path
"LOG_LEVEL": "info" // Optional: Set log level
},
"disabled": false
}
After configuring, you can run the server accordingly.
Imagine you are working on a complex project where understanding code functionality is critical. By leveraging the explain_code
tool, you can provide detailed context to your team or future you. For example:
{
"tool": "explain_code",
"code": "<The actual code string>"
}
For routine debugging and improving code quality:
{
"tool": "edit_code",
"original_code": "<The original code>",
"instructions": "<Instructions on how to edit>"
}
And for testing generated edits:
{
"tool": "test_code",
"edited_code": "<The edited code>",
"test_cases": "<Test cases to validate the changes>"
}
These tools help streamline the development process, ensuring that every change is both efficient and effective.
This server supports a wide range of MCP clients including Claude Desktop, Continue, and Cursor. Below is a compatibility matrix highlighting supported features:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ (Tools Only) | ✅ (Limited) | ❌ |
Feature | Performance | Compatibility |
---|---|---|
Code Explanation | High | ✔ |
Code Review | Medium-High | ✔ |
Code Fixing | High | ✔ |
Code Editing & Testing | High | ✔ |
Advanced users can extend the functionality by incorporating custom prompts and resource configurations. To enhance security, you should always protect your environment variables from unauthorized access.
Here’s an example of advanced configuration:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
A1: The server uses secure JSON requests over stdio, ensuring data integrity and confidentiality.
A2: Yes, you can configure the server to support multiple clients by adding more entries in the mcpServers
array.
A3: You should regularly update your CLI and restart the server to ensure compatibility and responsiveness. If issues persist, check for updates in the official documentation.
A4: Optimize by refining prompts and reducing unnecessary commands. Implement batch processing where possible to reduce overhead.
A5: The server is tested on major operating systems but may require adjustments for highly specialized or niche environments. Always test in a controlled environment before deploying.
Contributors are welcome to enhance the functionality and stability of ClaudeCode-MCP Server. Key guidelines include:
Explore the broader MCP ecosystem at MCP Official Website for additional resources, including documentation, tutorials, and community engagement platforms. Join forums or communities dedicated to Model Context Protocol to share insights and collaborate with other developers on related projects.
By leveraging ClaudeCode-MCP Server, AI developers can build robust solutions that enhance productivity and streamline workflows, ensuring smooth integration across a variety of tools and applications.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration