execute_command
Run shell commands on your system to automate tasks, manage files, and control PC operations through direct command execution.
Instructions
Execute shell commands on the system. SECURITY WARNING: This tool provides direct system access. Only use with trusted commands. Commands run with the same permissions as the MCP server process.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The shell command to execute | |
| workingDirectory | No | The working directory for command execution (optional) |
Implementation Reference
- src/index.ts:457-480 (handler)Handler for the 'execute_command' tool. Executes the shell command using the promisified 'exec' function from Node.js child_process module, with optional working directory. Returns stdout, stderr, and success status in JSON format.case "execute_command": { const command = args.command as string; const workingDirectory = args.workingDirectory as string | undefined; const options = workingDirectory ? { cwd: workingDirectory } : {}; const { stdout, stderr } = await execAsync(command, options); return { content: [ { type: "text", text: JSON.stringify( { stdout: stdout, stderr: stderr, success: true, }, null, 2 ), }, ], }; }
- src/index.ts:175-188 (schema)Input schema definition for the 'execute_command' tool, specifying a required 'command' string parameter and an optional 'workingDirectory' string.inputSchema: { type: "object", properties: { command: { type: "string", description: "The shell command to execute", }, workingDirectory: { type: "string", description: "The working directory for command execution (optional)", }, }, required: ["command"], },
- src/index.ts:172-189 (registration)Registration of the 'execute_command' tool in the TOOLS array, which is returned by the ListTools handler. Includes name, description, and input schema.{ name: "execute_command", description: "Execute shell commands on the system. SECURITY WARNING: This tool provides direct system access. Only use with trusted commands. Commands run with the same permissions as the MCP server process.", inputSchema: { type: "object", properties: { command: { type: "string", description: "The shell command to execute", }, workingDirectory: { type: "string", description: "The working directory for command execution (optional)", }, }, required: ["command"], }, },