mcp-server-for-powershell
MCP server for PowerShell
Disclaimer
Unofficial Implementation: This project is an independent open-source software project. It is not affiliated with, endorsed by, sponsored by, or associated with Microsoft Corporation or the PowerShell team.
Trademarks: "PowerShell" and the PowerShell logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks cited herein are the property of their respective owners. Use of these names is for descriptive purposes only (nominative fair use) to indicate compatibility.
Related MCP server: mcp-server-docker
Installation
Run directly with uv (recommended):
uvx mcp-server-for-powershellpip:
pip install mcp-server-for-powershelluv:
uv pip install mcp-server-for-powershell
Configuration
The server can be configured using the following command-line arguments:
Argument | Description | Default |
| List of allowed PowerShell commands. If empty, all are allowed (subject to restrictions). |
|
| List of restricted PowerShell commands. | Safe defaults |
| List of restricted directories. | System directories |
| PowerShell Language Mode: |
|
| Initial working directory. | Current Directory |
Language Modes
0 (NoLanguage): No script execution allowed.
1 (ConstrainedLanguage): Restricts access to sensitive language elements (default).
2 (RestrictedLanguage): Only allows basic commands.
3 (FullLanguage): Unrestricted access.
Security Profiles
We recommend different configurations based on your security needs:
Default (Balanced)
By default, the server runs in ConstrainedLanguage mode with a curated blocklist of dangerous commands and restricted system directories. This provides "good enough" defaults for general use, preventing common dangerous operations while allowing most read-only and safe actions.
uvx mcp-server-for-powershellSafe Mode (Strict)
For environments requiring stricter controls, use NoLanguage mode (--language-mode 0). Only built-in commands and cmdlets can be executed.
uvx mcp-server-for-powershell --language-mode 0Nuclear Mode (Allow-List Only)
For the highest security "nuclear" option, explicitly whitelist ONLY the commands you need (e.g., allow get-items only). This blocks everything else by default.
uvx mcp-server-for-powershell --allowed-commands Get-Item Get-ChildItem Get-ContentLicense
mcp-server-for-powershell is provided as-is under the MIT license.
Available Tools
1 toolrun_powershellA
Executes PowerShell commands based on a structured JSON definition.
This tool allows you to run PowerShell commands safely strings.
It expects a JSON string that defines the command(s), parameters, pipelines, and sequences.
Args:
json: A JSON string defining the command structure.
Structure examples:
1. Single Command:
[{"command": "Get-Item", "parameters": ["."]}]
2. .NET Static Method:
[{"command": "[System.Math]::Sqrt", "parameters": [16]}]
# Generates: [System.Math]::Sqrt(16)
3. Command with Named Parameters:
[{"command": "Get-Item", "parameters": {"-Path": "."}}]
4. Pipeline:
[{"command": "Get-Process", "then": {"command": "Select-Object", "parameters": ["Name"]}}]
5. Sequence (Multiple commands):
[{"command": "mkdir", "parameters": ["test"]}, {"command": "cd", "parameters": ["test"]}]
Returns:
The standard output of the executed PowerShell command(s), or an error message if execution fails.
Inputs: json (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusion or overlap. The agent can uniquely identify the tool's purpose without ambiguity.
The single tool name follows a clear verb_noun pattern (run_powershell), which is consistent and readable. Since there's only one tool, no convention conflicts exist.
The server has only one tool for the broad domain of PowerShell execution. While the tool is versatile, it forces the agent to encode all operations as complex JSON, which is less ergonomic than dedicated tools for common tasks. The count is borderline.
The single tool can theoretically execute any PowerShell command, covering the domain of command execution comprehensively. However, it lacks specialized tools for session management, script handling, or error recovery, which may be needed for complex workflows.
Maintenance
Related MCP Connectors
Related MCP Servers
- MIT
- MIT
- MIT
- AGPL 3.0