execute_command
Execute shell commands on your system to automate tasks, run scripts, or perform system operations through direct command line access.
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)The handler logic for the 'execute_command' tool. It executes the provided shell command using Node.js child_process.exec (promisified as execAsync), optionally in a specified working directory, and returns stdout, stderr, and success status.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:172-189 (registration)Registration of the 'execute_command' tool in the TOOLS array, including name, description, and input schema. This is used by the listTools handler.{ 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"], }, },