The claude-code-mcp server enables you to harness Claude Code's capabilities through an MCP server implementation. It provides tools like code explanation, review, fixing, editing, testing, and more by interfacing with your locally installed Claude Code command.
Before installing, ensure you have:
Run the server directly without installation:
npx @kunihiros/claude-code-mcp
Install the package globally for command-line access:
npm install -g claude-code-mcp
Then run it as a command:
claude-code-mcp
You must configure the environment variables using one of these methods:
Add this to your MCP Host application settings:
"claude-code-server": {
"command": "npx",
"args": [
"-y",
"@kunihiros/claude-code-mcp"
],
"env": {
"CLAUDE_BIN": "/path/to/your/claude/executable",
"LOG_LEVEL": "info"
},
"disabled": false
}
Create a .env
file in the directory where you run the command:
CLAUDE_BIN=/path/to/your/claude/executable
LOG_LEVEL=info
Create a .claude-code-mcp.env
file in your home directory:
CLAUDE_BIN=/path/to/your/claude/executable
LOG_LEVEL=info
CLAUDE_BIN
: Required - Full path to your Claude CLI executable
Example: /home/linuxbrew/.linuxbrew/bin/claude
or C:\Users\YourUser\AppData\Local\bin\claude.exe
LOG_LEVEL
: Optional - Set log level (debug, info, warn, error)The server provides several tools for working with code:
explain_code
: Provides detailed explanations of given codereview_code
: Reviews code for issues and improvementsfix_code
: Fixes bugs or issues in the provided codeedit_code
: Edits code based on specific instructionstest_code
: Generates tests for the given codesimulate_command
: Simulates command executionyour_own_query
: Sends custom queries with context/tmp/
folderThere 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.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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.
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.