win-cli-mcp-server
Hardened MCP server providing controlled access to PowerShell, CMD, Git Bash, and SSH from MCP clients like Claude Desktop.
README
win-cli-mcp-server
Hardened MCP server for Windows CLI and SSH interactions. Provides controlled access to PowerShell, CMD, Git Bash, and remote systems via SSH from MCP clients like Claude Desktop.
Fork Lineage
This is a maintained, hardened fork:
SimonB97/win-cli-mcp-server (original, development stalled) -> delorenj/super-win-cli-mcp-server (super-win-cli variant) -> this repo (bug fixes, hardening, dependency updates)
The original project is no longer actively maintained. This fork fixes critical bugs, updates dependencies, and is used in production daily.
What This Fork Fixes
Critical
- GUI window popups -- Added
windowsHide: truetochild_process.spawn(). Shell windows no longer flash on screen during MCP execution. - SSH event listener leak -- Reconnection cycles accumulated duplicate handlers on the ssh2
Clientinstance, causing memory leaks. Fixed by creating a freshClienton each reconnect and using.once()for connection-scoped events. - SSH stderr silently dropped -- When stdout had content, stderr was discarded (
output || errorOutput). Now both streams are combined. - Silent config fallback on BOM -- UTF-8 BOM in
config.jsoncausedJSON.parse()to throw, silently falling back to restrictive defaults. BOM is now stripped before parsing.
High
- Dead dependency removed --
@modelcontextprotocol/server-memory-dynamicpointed tofile:../servers/src/memory(author's local dev path). Removed. - SSH agent auth support -- Config validation required
passwordorprivateKeyPath. If neither was specified, the entire config load failed. Now optional -- ssh2 falls back to ssh-agent automatically. - SIGTERM handler -- Only SIGINT triggered cleanup. When the parent process sends SIGTERM (common when Claude Desktop restarts), SSH connections now close gracefully.
- MCP SDK updated -- Jumped from v1.0.1 to v1.29.0 (28 versions of bug fixes, security patches, protocol improvements). Zero breaking changes.
- npm audit clean -- All known vulnerabilities resolved.
Cleanup
- Dead code removed --
resolveCommandPath,isPathAllowed,validateWorkingDirectory,normalizeWindowsPath(exported but never imported). Unused imports (exec,promisify) also removed. @types/ssh2moved to devDependencies -- Type packages don't belong in production deps.- Output size cap -- Shell output is now capped at 1MB to prevent OOM on commands that dump large outputs. Truncated output includes a notice.
Installation
Add to your claude_desktop_config.json:
{
"mcpServers": {
"win-cli": {
"command": "node",
"args": [
"C:/path/to/win-cli-mcp-server/dist/index.js",
"--config",
"C:/path/to/win-cli-mcp-server/config.json"
]
}
}
}
Or clone and set up:
git clone https://github.com/mhprol/win-cli-mcp-server.git
cd win-cli-mcp-server
npm install
npm run build
Configuration
Copy config.example.json to config.json and customize:
{
"security": {
"maxCommandLength": 50000,
"blockedCommands": [],
"blockedArguments": [],
"allowedPaths": [],
"restrictWorkingDirectory": false,
"logCommands": true,
"maxHistorySize": 2000,
"commandTimeout": 600,
"enableInjectionProtection": false
},
"shells": {
"powershell": {
"enabled": true,
"command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": ["-NoProfile", "-NoLogo", "-NonInteractive", "-Command"],
"blockedOperators": []
},
"cmd": {
"enabled": true,
"command": "cmd.exe",
"args": ["/c"],
"blockedOperators": []
},
"gitbash": {
"enabled": true,
"command": "C:\\Program Files\\Git\\bin\\bash.exe",
"args": ["--norc", "-c"],
"blockedOperators": []
}
},
"ssh": {
"enabled": true,
"defaultTimeout": 30,
"maxConcurrentSessions": 5,
"keepaliveInterval": 10000,
"keepaliveCountMax": 3,
"readyTimeout": 20000,
"connections": {
"my-server": {
"host": "192.168.1.100",
"port": 22,
"username": "user",
"privateKeyPath": "C:\\Users\\you\\.ssh\\id_ed25519"
}
}
}
}
SSH authentication priority: explicit key > password > ssh-agent (automatic).
Config notes:
- File must be valid JSON without BOM (UTF-8, no BOM). Most editors default to this.
config.jsonis gitignored to protect credentials. Useconfig.example.jsonas template.- Shell
commandpaths should point to the actual executable (e.g.,pwsh.exefor PS7, notpowershell.exefor PS5.1).
Tools
| Tool | Description |
|---|---|
execute_command |
Run a command in PowerShell, CMD, or Git Bash |
get_command_history |
Retrieve history of executed commands |
ssh_execute |
Execute a command on a configured remote host |
ssh_disconnect |
Close an SSH connection |
Security
This server provides direct access to your system's command line and remote systems via SSH. The default configuration is intentionally open for trusted single-user environments. For shared or exposed setups:
- Enable
restrictWorkingDirectoryand setallowedPaths - Populate
blockedCommandsandblockedArguments - Enable
enableInjectionProtection - Set
blockedOperatorsper shell - Use key-based SSH auth, never store passwords in config
Credits
- Simon Benedict -- Original
win-cli-mcp-serverauthor - delorenj --
super-win-clifork with extended config - Hardening, bug fixes, and maintenance by Matt Prol
License
MIT -- see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。