run_command
Execute shell commands in your project directory to run npm install, git operations, tests, and other development tasks directly from Claude Desktop.
Instructions
Execute a shell command in the projects directory. Use for running npm install, git commands, tests, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Shell command to execute | |
| cwd | No | Working directory (relative to projects directory or absolute) |
Implementation Reference
- index.js:283-299 (handler)The main handler function for the 'run_command' tool. It resolves the working directory, executes the shell command using execAsync, captures stdout and stderr, and returns the output in the MCP response format.async runCommand(command, cwd) { const resolvedCwd = cwd ? this.resolvePath(cwd) : PROJECTS_DIR; const { stdout, stderr } = await execAsync(command, { cwd: resolvedCwd }); let output = ''; if (stdout) output += `Output:\n${stdout}\n`; if (stderr) output += `Errors:\n${stderr}\n`; return { content: [ { type: 'text', text: output || 'Command executed successfully (no output)', }, ], }; }
- index.js:118-131 (schema)Input schema definition for the 'run_command' tool, specifying 'command' as required string and 'cwd' as optional string.inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute', }, cwd: { type: 'string', description: 'Working directory (relative to projects directory or absolute)', }, }, required: ['command'], },
- index.js:115-132 (registration)Registration of the 'run_command' tool in the tools array passed to server.setTools(), including name, description, and schema.{ name: 'run_command', description: 'Execute a shell command in the projects directory. Use for running npm install, git commands, tests, etc.', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute', }, cwd: { type: 'string', description: 'Working directory (relative to projects directory or absolute)', }, }, required: ['command'], }, },
- index.js:175-176 (registration)Request handler switch case that routes 'run_command' calls to the runCommand method.case 'run_command': return await this.runCommand(args.command, args.cwd);