command_execution
Execute PowerShell or CMD commands on Windows, capture output, and monitor progress with timeout and truncation controls.
Instructions
Execute Windows commands with reliable output capture and agentic sampling.
RATIONALE: Consolidates PowerShell and CMD execution into a single async portmanteau. Uses asyncio.to_thread() to ensure the MCP event loop is never blocked. Integrates with FastMCP 3.2 Context for real-time telemetry and sampling.
PATTERNS:
Non-blocking: Subprocess runs in a thread pool.
Security: Argument validation for length (shlex not fully applicable for Windows non-shell).
Feedback: ctx.info and ctx.report_progress for industrial observability.
Args: action: Execution environment ("powershell" or "cmd"). command: The command string to execute. working_directory: Optional CWD for the command. timeout_seconds: Hard timeout (1-300s, default: 30). max_output_size: Truncation limit for high-volume logs. ctx: FastMCP Context for telemetry and sampling (injected).
Examples: - command_execution(action="powershell", command="Get-Service | Where-Object Status -eq 'Running'") - command_execution(action="cmd", command="dir /s /b *.log")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| command | Yes | ||
| working_directory | No | ||
| timeout_seconds | No | ||
| max_output_size | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||