run_command
Execute shell commands in your project directory to run npm install, git operations, tests, and other development tasks directly from your local environment.
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 core handler function that executes the provided shell command in the resolved working directory (defaulting to PROJECTS_DIR), captures stdout and stderr, and returns formatted text output.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 for the 'run_command' tool, requiring a 'command' string and optionally accepting 'cwd'.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 ListToolsRequestSchema response, including name, description, and input 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 (handler)Dispatch handler within the CallToolRequestSchema switch statement that routes 'run_command' calls to the runCommand method.case 'run_command': return await this.runCommand(args.command, args.cwd);