claude_code_task
Execute coding tasks using Claude Code CLI to build applications, create APIs, and debug scripts while maintaining interaction through Claude Desktop.
Instructions
Execute a coding task using Claude Code CLI
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | The coding task to execute | |
| project_path | No | Path to the project directory |
Implementation Reference
- server.js:43-60 (schema)Tool schema definition for claude_code_task with input parameters (task: required string, project_path: optional string)name: "claude_code_task", description: "Execute a coding task using Claude Code CLI", inputSchema: { type: "object", properties: { task: { type: "string", description: "The coding task to execute" }, project_path: { type: "string", description: "Path to the project directory", default: "" } }, required: ["task"] } },
- server.js:135-136 (registration)Registration case that routes claude_code_task calls to the executeClaudeCodeTask handler functioncase 'claude_code_task': return await this.executeClaudeCodeTask(args.task, args.project_path);
- server.js:165-212 (handler)Main handler implementation that spawns claude-code CLI process with the task, captures stdout/stderr, and returns formatted resultsasync executeClaudeCodeTask(task, projectPath = '') { return new Promise((resolve, reject) => { const fullPath = projectPath ? path.join(this.workingDir, projectPath) : this.workingDir; const claudeCode = spawn('claude-code', [task], { cwd: fullPath, stdio: ['pipe', 'pipe', 'pipe'], env: { ...process.env, ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY } }); let stdout = ''; let stderr = ''; claudeCode.stdout.on('data', (data) => { stdout += data.toString(); }); claudeCode.stderr.on('data', (data) => { stderr += data.toString(); }); claudeCode.on('close', (code) => { if (code === 0) { resolve({ content: [ { type: "text", text: `Claude Code task completed successfully:\n\n${stdout}` } ] }); } else { resolve({ content: [ { type: "text", text: `Claude Code task failed (exit code ${code}):\n\nSTDOUT:\n${stdout}\n\nSTDERR:\n${stderr}` } ] }); } }); claudeCode.on('error', (error) => { reject(new Error(`Failed to execute Claude Code: ${error.message}`)); }); }); }