# pwsh-exec-mcp [Health: Active]

**Category:** 🖥️ Command Line  
**Repository:** https://github.com/Jason26214/pwsh-exec-mcp  
**GitHub Stars:** 1  
**Views:** 19  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/pwsh-exec-mcp

## Description
A minimal, transparent PowerShell 7 MCP for Windows — one tool: raw exit code, stdout, stderr.

## Tools
Capabilities this server exposes over MCP:

- **run_command** — Execute a command in a new PowerShell (pwsh 7) process. Stateless — no state persists between calls.

NOT for long-running tasks. Hard cap is 300 seconds (5 minutes); there is no background mode.
Do NOT use for: installers (Ollama, VS, .NET SDK, etc.), large builds, package managers that
may exceed 5 minutes (npm install on cold cache, pip install torch, etc.), dev servers, or
anything interactive.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "pwsh-exec-mcp": {
    "command": "uvx",
    "args": ["pwsh-exec"],
    "env": {
      "PWSH_EXEC_DEFAULT_DIR": ""
    }
  }
}
```

**Requires environment variables:** `PWSH_EXEC_DEFAULT_DIR` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What pwsh-exec-mcp MCP server does

The pwsh-exec-mcp MCP server gives an MCP client a narrow interface for executing commands in PowerShell 7 on Windows. Its single tool, `run_command`, accepts a command string, a timeout in seconds, and an optional absolute working directory.

Each invocation is isolated in a newly launched `pwsh` process. The response preserves the command's exit status and separates its standard output from standard error. It does not summarize or reinterpret command results. Empty streams remain identifiable, and non-zero exit codes are returned instead of being hidden.

This design fits agents that need to run commands such as Git operations, scripts, or local CLI utilities and inspect the terminal result directly. It is not a replacement for a persistent terminal session or a service runner.

## How it works

The client starts the server over stdio with `uvx pwsh-exec`. A call to `run_command` launches PowerShell 7, detaches standard input to avoid interactive hangs, and waits synchronously for completion. The timeout must be between 1 and 300 seconds. If it expires, the server terminates the PowerShell process and its descendants rather than leaving child processes running.

Output is formatted with an exit-code section followed by labeled stdout and stderr sections, plus timing information. If either stream exceeds 500 lines, the first and last 250 lines are retained. This limits context growth while preserving both the beginning and end of long output.

The pwsh-exec-mcp MCP server also forces UTF-8 output and refreshes user-scope `PATH` values from the Windows registry on each call. Registry environment values that use expandable syntax are expanded, allowing tools installed after the MCP host started to be discovered.

## Setup and configuration

The host system must be Windows with PowerShell 7 (`pwsh`) available on `PATH`. Windows PowerShell 5.1, invoked as `powershell.exe`, is not the required runtime. `uv` is also required because the standard launch command uses its `uvx` runner; cloning the repository is not necessary for this setup.

For a generic MCP client, configure the server command as:

```text
uvx pwsh-exec
```

Claude Desktop should use `cmd /c` around that command:

```json
{
  "mcpServers": {
    "pwsh-exec": {
      "command": "cmd",
      "args": ["/c", "uvx", "pwsh-exec"]
    }
  }
}
```

`working_directory` takes priority when supplied in a tool call. Without it, the server checks `PWSH_EXEC_DEFAULT_DIR`; if that variable is unset or blank, it uses `%TEMP%\\pwsh-exec`. Set the environment variable in the MCP client configuration to choose another default directory.

## Tools and capabilities

The pwsh-exec-mcp MCP server provides one tool:

- `run_command`: Runs a PowerShell command or script.
- `command`: Required string containing the command.
- `timeout`: Required integer in seconds, from 1 through 300.
- `working_directory`: Optional absolute path for the process.

The server supports raw exit-code inspection, separate stdout and stderr capture, UTF-8 output across Windows locales, fresh `PATH` lookup, process-tree cleanup on timeout, detached stdin, and bounded long-output handling.

## Limitations and notes

Calls are stateless. Directory changes, variables, and other shell state disappear when the process ends. Pass `working_directory` on later calls or combine dependent commands into one invocation.

Execution uses the permissions of the host user and does not elevate to administrator. Calls are synchronous and capped at five minutes, so persistent shells, background jobs, watchers, development servers, installers, and other long-running work are outside the intended scope.

_Full upstream README: https://allmcps.com/mcp/pwsh-exec-mcp/readme_

