run_command
Execute shell commands like npm install or build in a sandboxed project environment for web development automation.
Instructions
Execute a shell command in the project sandbox (e.g. npm install, npm run build). Max timeout 5 minutes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID (UUID or url_id) | |
| command | Yes | Shell command to execute | |
| cwd | No | Working directory (default: /home/user/project) | |
| timeout_ms | No | Timeout in milliseconds (default: 120000, max: 300000) |
Implementation Reference
- src/index.ts:200-222 (handler)The handler function for the run_command tool. It calls client.runCommand() with parameters (project_id, command, cwd, timeout_ms), formats the output showing exit code, stdout, and stderr, and handles errors.
async (params) => { try { const result = await client.runCommand(params.project_id, { command: params.command, cwd: params.cwd, timeout_ms: params.timeout_ms, }); let text = `Exit code: ${result.exit_code}`; if (result.stdout) { text += `\n\nSTDOUT:\n${result.stdout}`; } if (result.stderr) { text += `\n\nSTDERR:\n${result.stderr}`; } return { content: [{ type: 'text' as const, text }] }; } catch (err: any) { return { content: [{ type: 'text' as const, text: `Error: ${err.message}` }], isError: true }; } }, - src/client.ts:136-141 (helper)The runCommand method in AICre8Client class that makes the actual POST request to /projects/{projectId}/run endpoint with command parameters and returns exit_code, stdout, and stderr.
async runCommand( projectId: string, params: { command: string; cwd?: string; timeout_ms?: number }, ): Promise<{ exit_code: number; stdout: string; stderr: string }> { return this.request('POST', `/projects/${projectId}/run`, params); } - src/index.ts:188-189 (registration)Registration of the run_command tool with the MCP server using server.tool() method.
server.tool( 'run_command', - src/index.ts:191-199 (schema)Zod schema definition for run_command tool parameters: project_id (required), command (required), cwd (optional), and timeout_ms (optional with max 300000ms).
{ project_id: z.string().describe('Project ID (UUID or url_id)'), command: z.string().describe('Shell command to execute'), cwd: z.string().optional().describe('Working directory (default: /home/user/project)'), timeout_ms: z .number() .optional() .describe('Timeout in milliseconds (default: 120000, max: 300000)'), },