Skip to main content
Glama
MCP PowerShell Server

MCP PowerShell Server

by saimanish1

MCP PowerShell Server

A memory-optimized MCP server for executing PowerShell commands on Windows.

Why This Exists

This server was created to solve a common Windows development issue: many AI coding assistants (like Claude Code) attempt to execute PowerShell commands through Bash on Windows, which fails because Bash doesn't understand PowerShell syntax. This server provides direct PowerShell execution with proper quoting, path handling, and memory optimization.

Instead of fighting with Bash translation layers or constantly reminding the AI to use cmd.exe, this MCP server gives AI assistants direct, reliable access to PowerShell with all the Windows-specific features they need.

Related MCP server: COP Plug

Features

  • PowerShell-only execution with -EncodedCommand for robust quoting

  • Memory optimized with 64KB default output limit, 2MB maximum

  • Buffer-based output handling to prevent memory leaks

  • Process tree killing with taskkill /t /f

  • Timeout protection (default 60 seconds, max 10 minutes)

  • Cross-platform MCP client compatibility

Installation

npm install

Usage

Start the server

node mcp-shell-server.mjs

Configure with MCP clients

Add to your MCP client configuration (e.g., Gemini CLI settings.json):

{
  "mcpServers": {
    "mcp-powershell-server": {
      "command": "node",
      "args": ["path/to/mcp-shell-server/mcp-shell-server.mjs"],
      "env": {
        "MCP_SHELL_EXE": "pwsh.exe"  // Optional: override shell executable
      }
    }
  }
}

Tool: run_shell_command

Execute PowerShell commands with memory and timeout protection.

Parameters

  • command (required): PowerShell command/script to execute

  • cwd (optional): Working directory

  • timeoutMs (optional): Timeout in milliseconds (max 10 minutes)

  • maxOutputBytes (optional): Max output bytes per stream (default 64KB, max 2MB)

Response

{
  "stdout": "...",
  "stderr": "...",
  "exitCode": 0,
  "signal": null,
  "truncated": false,
  "timedOut": false,
  "platform": "win32",
  "shell": "pwsh.exe"
}

Examples

List files

{
  "command": "Get-ChildItem -Path ."
}

Get system information

{
  "command": "Get-ComputerInfo"
}

With custom timeout and output limit

{
  "command": "Get-Process",
  "timeoutMs": 30000,
  "maxOutputBytes": 128000
}

Memory Optimization

  • Default output limit: 64KB per stream

  • Maximum output limit: 2MB per stream

  • Buffer chunks instead of string concatenation

  • Automatic cleanup of event listeners

  • Process tree termination on timeout/truncation

Security Notes

  • Commands run with user permissions

  • PowerShell ExecutionPolicy bypassed for MCP commands

  • Consider implementing command whitelisting for production use

  • Use working directory restrictions if needed

Environment Variables

  • MCP_SHELL_EXE: Override PowerShell executable (pwsh.exe or powershell.exe)

  • Standard environment variables are passed through to child processes

Requirements

  • Node.js 18+

  • Windows OS

  • PowerShell (pwsh.exe recommended)

License

MIT

Available Tools

1 tool
run_shell_commandB

Execute commands using PowerShell on Windows (PowerShell-only). Returns stdout, stderr, exit code, signal, and flags for timeout/truncation.

Inputs: command (required), cwd, timeoutMs, maxOutputBytes.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only a single tool, there is no possibility of confusion—an agent cannot misselect. The tool's purpose (execute PowerShell commands) is unambiguous.

    Naming Consistency5/5

    run_shell_command follows a clear verb_noun snake_case convention. With one tool there is no inconsistency to speak of.

    Tool Count3/5

    A single tool makes the surface feel thin, though for a command-execution server one general-purpose runner is defensible. It earns its place but offers no specialization.

    Completeness4/5

    The tool covers core execution output (stdout, stderr, exit code, signal, timeout/truncation flags), which is the essential lifecycle for running commands. Minor gaps exist around session persistence and working-directory management that agents may need to work around.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to securely manage and execute commands on remote Windows servers via WinRM, including PowerShell execution, system information retrieval, and service management.
      6
      13 PyPI
      6
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to execute PowerShell commands, manage files, inspect projects, run Git operations, and monitor system information on Windows through a local MCP server.
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to run PowerShell commands and manage Windows services without intrusive console windows, while also supporting remote execution via SSH and WinRM.
      20
      187 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Windows-native developer orchestration for Claude Code and Codex with PowerShell discovery, capability routing, safety-gated execution, package management, and sandbox-based isolation.
      MIT