WI

Windows CLI MCP Server: Secure PowerShell, CMD Access

Secure Windows command-line access with an MCP server for controlled PowerShell, CMD, and Git Bash shell sessions.

Quick Install
npx -y @SimonB97/win-cli-mcp-server

Overview

This project implements a Model Context Protocol (MCP) server that provides controlled Windows command-line access. It lets an MCP-capable client open sandboxed shell sessions (PowerShell, CMD, or Git Bash) on a Windows host and exchange I/O over an authenticated, auditable channel. The server focuses on security controls such as command whitelisting, session time limits, TLS, and token-based authentication so automated tools or AI agents can interact with a Windows CLI without granting unrestricted shell access.

For developers, the MCP server is useful when you need remote programmatic access to Windows shells from an orchestration system, a language model agent, or a developer tool that understands MCP. It standardizes session lifecycle management (create/attach/detach/terminate), centralizes auditing, and reduces the attack surface by restricting available binaries and arguments.

Features

  • Expose PowerShell, cmd.exe and Git Bash shells via MCP-compatible sessions
  • Token-based authentication and TLS for encrypted transport
  • Per-session configuration: max duration, stdout/stderr limits, env overrides
  • Command and argument whitelisting to reduce risk
  • Audit logs of session start/stop and command execution
  • Session concurrency and global resource limits
  • Configurable shell startup environment (working dir, PATH tweaks)
  • Lightweight server binary suitable for local install or deployment

Installation / Configuration

  1. Clone the repository:
git clone https://github.com/SimonB97/win-cli-mcp-server.git
cd win-cli-mcp-server
  1. Build (example for a Go-based project — see repo README for exact build instructions):
# if the project uses Go modules
go build -o win-cli-mcp-server ./cmd/server
  1. Create a YAML configuration file (example below) and start the server:
# config.yml
listen: "0.0.0.0:8443"
tls:
  cert: "C:\\certs\\server.crt"
  key:  "C:\\certs\\server.key"
auth:
  tokens:
    - "replace-with-secret-token"
allowed_shells:
  - powershell
  - cmd
  - git-bash
whitelist:
  commands:
    - "git"
    - "dir"
    - "ipconfig"
session:
  max_seconds: 600
  max_output_bytes: 10485760
logging:
  path: "C:\\var\\log\\win-cli-mcp-server.log"
  level: "info"

Start the server with the config file:

./win-cli-mcp-server --config config.yml
# or on Windows
win-cli-mcp-server.exe --config C:\path\to\config.yml

Command-line flags commonly supported:

  • –config PATH Path to YAML/JSON configuration
  • –listen HOST:PORT Bind address and port
  • –tls-cert PATH TLS certificate
  • –tls-key PATH TLS key
  • –log PATH Log file path
  • –debug Enable verbose debug logging

Table: Key configuration options

KeyPurpose
listenAddress and port to bind (e.g. 0.0.0.0:8443)
tls.cert / tls.keyPaths to TLS certificate and private key
auth.tokensStatic bearer tokens allowed to authenticate requests
allowed_shellsWhich shells the server can spawn (powershell, cmd, git-bash)
whitelist.commandsList of permitted command basenames
session.max_secondsMaximum lifetime of a single session
logging.pathFile to write audit and server logs to

Available Resources

  • Source and releases: https://github.com/SimonB97/win-cli-mcp-server
  • MCP (Model Context Protocol): use the server’s MCP endpoints to manage sessions; the server implements create/attach/resize/terminate lifecycle operations