Skip to main content
Glama

Windows Automation MCP Server

run_powershell

Execute PowerShell commands and scripts to automate Windows system administration tasks, manage processes, and control system operations through the Windows Automation MCP Server.

Instructions

执行 PowerShell 命令或脚本

Input Schema

NameRequiredDescriptionDefault
commandYesPowerShell 命令或脚本
timeoutNo超时时间(毫秒,可选)

Input Schema (JSON Schema)

{ "properties": { "command": { "description": "PowerShell 命令或脚本", "type": "string" }, "timeout": { "description": "超时时间(毫秒,可选)", "type": "number" } }, "required": [ "command" ], "type": "object" }

Implementation Reference

  • Registration of the 'run_powershell' tool including name, description, and input schema in the getToolDefinitions method.
    { name: 'run_powershell', description: '执行 PowerShell 命令或脚本', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'PowerShell 命令或脚本' }, timeout: { type: 'number', description: '超时时间(毫秒,可选)' }, }, required: ['command'], }, },
  • The core handler function that executes the PowerShell command using child_process.execAsync, handles timeout, captures output and errors.
    async runPowerShell(command, timeout = 30000) { try { const { stdout, stderr } = await execAsync( `powershell -Command "${command.replace(/"/g, '\\"')}"`, { shell: 'powershell.exe', timeout, maxBuffer: 1024 * 1024 * 10, // 10MB } ); return { success: true, output: stdout.trim(), error: stderr.trim(), command }; } catch (error) { return { success: false, error: error.message, command }; } }
  • Dispatch logic in the executeTool method that routes 'run_powershell' calls to the runPowerShell handler.
    case 'run_powershell': return await this.runPowerShell(args.command, args.timeout);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eva-wanxin-git/windows-automation-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server