Use Claude Code as an MCP server
You can use Claude Code itself as an MCP server that other applications can connect to:
bash
# Start Claude as a stdio MCP server
claude mcp serveThe command prints nothing when it starts. A stdio MCP server communicates over stdin and stdout, so a silent, blocked terminal means the server is running and waiting for a client to connect.
You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
json
{
"mcpServers": {
"claude-code": {
"type": "stdio",
"command": "claude",
"args": ["mcp", "serve"],
"env": {}
}
}
}Configuring the executable path: the command field must reference the Claude Code executable. If the claude command is not in your system's PATH, you'll need to specify the full path to the executable.
To find the full path:
bash
which claudeThen use the full path in your configuration:
json
{
"mcpServers": {
"claude-code": {
"type": "stdio",
"command": "/full/path/to/claude",
"args": ["mcp", "serve"],
"env": {}
}
}
}Without the correct executable path, you'll encounter errors like spawn claude ENOENT.
Tips:
- In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.
- This MCP server only exposes Claude Code's tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.