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.
npx -y @SimonB97/win-cli-mcp-serverOverview
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
- Clone the repository:
- Build (example for a Go-based project — see repo README for exact build instructions):
# if the project uses Go modules
- 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:
# or on Windows
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
| Key | Purpose |
|---|---|
| listen | Address and port to bind (e.g. 0.0.0.0:8443) |
| tls.cert / tls.key | Paths to TLS certificate and private key |
| auth.tokens | Static bearer tokens allowed to authenticate requests |
| allowed_shells | Which shells the server can spawn (powershell, cmd, git-bash) |
| whitelist.commands | List of permitted command basenames |
| session.max_seconds | Maximum lifetime of a single session |
| logging.path | File 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