run_command
Execute shell commands within project directories to manage development tasks, automate processes, and interact with codebases directly from the Claude interface.
Instructions
Run a shell command in the project directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Command to execute | |
| project_path | No | Directory to run command in |
Implementation Reference
- server.js:283-303 (handler)The main runCommand handler function that executes shell commands using Node.js exec() with proper path resolution and output formattingasync runCommand(command, projectPath = '') { return new Promise((resolve) => { const fullPath = projectPath ? path.join(this.workingDir, projectPath) : this.workingDir; exec(command, { cwd: fullPath }, (error, stdout, stderr) => { let output = ''; if (stdout) output += `STDOUT:\n${stdout}\n\n`; if (stderr) output += `STDERR:\n${stderr}\n\n`; if (error) output += `Error: ${error.message}`; resolve({ content: [ { type: "text", text: output || 'Command executed with no output' } ] }); }); }); }
- server.js:108-124 (schema)Tool registration with name, description, and input schema defining the command and optional project_path parametersname: "run_command", description: "Run a shell command in the project directory", inputSchema: { type: "object", properties: { command: { type: "string", description: "Command to execute" }, project_path: { type: "string", description: "Directory to run command in" } }, required: ["command"] } }
- server.js:147-148 (registration)Switch case that routes 'run_command' tool calls to the runCommand handler methodcase 'run_command': return await this.runCommand(args.command, args.project_path);