run_cmd
Execute CMD commands to automate Windows system tasks through the Windows Automation MCP Server.
Instructions
执行 CMD 命令
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | CMD 命令 | |
| timeout | No | 超时时间(毫秒,可选) |
Implementation Reference
- src/tools/powershell.js:107-123 (handler)The handler function that executes the CMD command using Node.js child_process.execAsync (promisified) with cmd.exe shell. It captures stdout/stderr, handles timeouts and buffer limits, and returns a structured response with success status, output, error, and the executed command.async runCmd(command, timeout = 30000) { try { const { stdout, stderr } = await execAsync(command, { shell: 'cmd.exe', timeout, maxBuffer: 1024 * 1024 * 10, }); return { success: true, output: stdout.trim(), error: stderr.trim(), command }; } catch (error) { return { success: false, error: error.message, command }; } }
- src/tools/powershell.js:24-35 (schema)The tool schema definition returned by getToolDefinitions(), specifying the name, description, and inputSchema for parameter validation (required 'command' string, optional 'timeout' number).{ name: 'run_cmd', description: '执行 CMD 命令', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'CMD 命令' }, timeout: { type: 'number', description: '超时时间(毫秒,可选)' }, }, required: ['command'], }, },
- src/tools/powershell.js:73-74 (registration)Registration and dispatching logic in the executeTool switch statement, which routes calls to the 'run_cmd' tool to the runCmd handler method.case 'run_cmd': return await this.runCmd(args.command, args.timeout);