claudecode-mcp
Local stdio MCP server that wraps the headless Claude Code CLI as MCP tools. Stateless, spawn-per-client.
Tools
claude_prompt { prompt, model?, system_prompt? }claude_prompt_with_context { prompt, context?, files?, model?, system_prompt? }claude_prompt_structured { prompt, schema, model?, system_prompt? }— usesclaude --json-schema; fails loudly if the installed CLI lacks that flag.
Build
npm install
npm run build
node dist/server.js
Register
Claude Code (~/.claude/mcp.json):
{
"mcpServers": {
"claudecode": {
"command": "node",
"args": ["/home/trevor/claudecode-mcp/dist/server.js"]
}
}
}
Test live
npm run test:live
Runs tiny real prompts against claude. Skipped unless CLAUDECODE_MCP_LIVE=1.
Design notes
- No session tracking. No
session_idin tool inputs.--no-session-persistencealways. - No
working_dirparameter. Usesprocess.cwd()of the MCP server process. - No timeout enforcement. Trusts CLI-native turn limits.
- Argv array spawning — never shell-interpolated.
- Sanitized child env:
NO_COLOR=1, inheritedPATH/HOME/auth. --bareis intentionally NOT used: it disables OAuth/keychain reads and would force ANTHROPIC_API_KEY. The MCP inherits whatever auth the user'sclaudeCLI is already configured with (OAuth, keychain, or env key).