MCP CMD
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP CMD check my system info and list what processes are running"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP CMD — Chạy lệnh Windows không bao giờ bị treo 🚀
MCP Server nhẹ, giúp AI assistant (Antigravity, Claude, Gemini CLI...) chạy lệnh CMD & PowerShell trên Windows an toàn, không bao giờ bị treo, với bảo mật đa tầng.
🔗 Repo: github.com/quangminh1212/MCP_CMD
Vấn đề gì được giải quyết?
Khi dùng AI coding assistant trên Windows, lệnh shell thường bị treo vĩnh viễn do:
Prompt chờ nhập liệu (y/n, password...)
Process zombie không tự tắt
Escape ký tự đặc biệt trong PowerShell
MCP CMD xử lý tất cả bằng cách:
✅ Đóng
stdinngay lập tức — không prompt nào block được✅ Tự kill cả process tree khi timeout — không zombie
✅ PowerShell chạy qua Base64 — hết lỗi escape
✅ Output giới hạn 10MB — không tràn bộ nhớ
✅ Phát hiện shell injection & lệnh nguy hiểm — cảnh báo bảo mật
✅ Chống path traversal & UNC injection — bảo vệ thư mục làm việc
Related MCP server: Windows CLI MCP Server
7 Tools có sẵn
Tool | Mô tả |
| Chạy 1 lệnh CMD đơn lẻ |
| Chạy nhiều lệnh tuần tự (dừng khi lỗi hoặc tiếp tục) |
| Chạy PowerShell an toàn, không lỗi escape |
| Xem thông tin hệ thống (OS, RAM, user) |
| Liệt kê các process đang chạy |
| Dọn dẹp process treo/zombie |
| Hiển thị cấu hình bảo mật & giới hạn runtime |
Cài đặt nhanh (3 bước)
1. Clone & cài đặt
git clone https://github.com/quangminh1212/MCP_CMD.git
cd MCP_CMD
npm install2. Thêm vào MCP config
Thêm đoạn sau vào file cấu hình MCP của bạn (ví dụ: .gemini/settings.json, claude_desktop_config.json):
{
"mcpServers": {
"cmd": {
"command": "node",
"args": ["C:\\path\\to\\MCP_CMD\\index.js"],
"autoApprove": ["cmd_run", "cmd_batch", "powershell_run", "system_info", "process_list", "process_cleanup", "show_security_rules"]
}
}
}⚠️ Thay
C:\\path\\to\\MCP_CMDbằng đường dẫn thực tế trên máy bạn.
3. Xong! 🎉
AI assistant của bạn giờ có thể chạy lệnh Windows mà không bao giờ bị treo.
Ví dụ sử dụng
Chạy lệnh CMD đơn giản
{
"name": "cmd_run",
"arguments": {
"command": "echo Hello && dir /b",
"cwd": "C:\\Projects",
"timeout": 30000
}
}Chạy nhiều lệnh liên tiếp
{
"name": "cmd_batch",
"arguments": {
"commands": [
{ "command": "npm install", "cwd": "C:\\Projects\\my-app" },
{ "command": "npm run build", "cwd": "C:\\Projects\\my-app" },
{ "command": "npm test", "cwd": "C:\\Projects\\my-app" }
],
"timeout": 60000,
"continueOnError": false
}
}Chạy PowerShell
{
"name": "powershell_run",
"arguments": {
"command": "Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Name, CPU",
"timeout": 15000
}
}Dọn dẹp process treo
{
"name": "process_cleanup",
"arguments": {
"maxAgeSeconds": 10,
"dryRun": false,
"includeNode": false
}
}Kiến trúc Anti-Hang
┌─────────────────────────────────────────────┐
│ MCP Client (AI Assistant) │
│ Gửi JSON-RPC request qua stdio │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ MCP CMD Server (Node.js) │
│ │
│ 1. spawn("cmd.exe", ["/c", command]) │
│ 2. child.stdin.end() ← đóng ngay │
│ 3. Thu stdout/stderr (giới hạn 5MB) │
│ 4. setTimeout → taskkill /T /F /PID │
│ 5. Trả kết quả khi xong hoặc timeout │
└─────────────────────────────────────────────┘Bảo vệ | Cách thực hiện |
Không treo khi chờ input |
|
Không process zombie |
|
Không tràn bộ nhớ | Output giới hạn 10MB |
Không popup GUI |
|
Không lỗi escape PS | PowerShell dùng |
Chống path traversal |
|
Phát hiện lệnh nguy hiểm | Cảnh báo |
Phát hiện shell injection | Cảnh báo khi dùng |
Giới hạn độ dài lệnh | Chặn lệnh > 8192 bytes |
Yêu cầu
Node.js v18+
Windows OS
Testing
npm testThe integration suite covers:
MCP stdio transport through
node index.jsWrapper startup through
wrapper.jsLauncher startup through
launcher.exePrompt/timeout anti-hang regression cases
Parallel execution queue behavior
Plain-text PowerShell error output
License
MIT © 2026 quangminh1212
Available Tools
8 toolscmd_admin_runA
Run a Windows CMD command with Administrator (elevated) privileges. Uses PowerShell Start-Process -Verb RunAs to launch an elevated cmd.exe. Output is captured via temp files since elevated processes cannot pipe stdio to non-elevated parents. Use this for commands that require admin rights (e.g., netsh, sc query, icacls, dism, sfc). NOTE: UAC prompt may appear if not already elevated.
Inputs: command (required), cwd, timeout.
cmd_batchA
Run multiple CMD commands one by one. Each command runs in its own cmd.exe /c process (no hanging). Stops on first failure unless continueOnError is true.
Inputs: commands (required), timeout, continueOnError.
cmd_runA
Run a Windows CMD command without hanging. Uses cmd.exe /c with stdin closed and process tree kill on timeout. Safe for any non-interactive command.
Inputs: command (required), cwd, timeout.
powershell_runB
Run a PowerShell command without hanging. Uses -NonInteractive -NoProfile flags to prevent prompts and speed up startup. Command is Base64-encoded to avoid escaping issues.
Inputs: command (required), cwd, timeout.
process_cleanupA
Find and kill hanging/orphaned cmd.exe and conhost.exe processes. Targets windowless CMD processes older than the specified age (default: 30 seconds). Use this to clean up stale processes left by Antigravity's run_command tool.
Inputs: dryRun, includeNode, maxAgeSeconds.
process_listA
List running cmd.exe, powershell.exe, node.exe, and conhost.exe processes. Useful for diagnosing hanging processes before cleanup.
Inputs: filter.
show_security_rulesB
Display current security configuration, restrictions, and runtime limits. Shows command length limits, timeout values, concurrency settings, dangerous command patterns, and MCP infrastructure protection rules.
Inputs: no named parameters.
system_infoA
Get basic Windows system info: OS, architecture, memory, username. Quick diagnostic.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
The execution tools are mostly distinct: cmd_run (non-elevated single), cmd_admin_run (elevated), cmd_batch (multiple), and powershell_run (different shell) each have clear roles. Minor conceptual overlap exists since cmd_batch with one command equals cmd_run, and process_list/process_cleanup are tightly related, but descriptions clarify boundaries well.
Naming mixes conventions: prefix/namespace style (cmd_run, cmd_admin_run, powershell_run, process_list) alongside noun_phrases (system_info) and verb_noun (show_security_rules). Patterns are readable but not uniform across the set.
Eight tools is well-scoped for a Windows command-execution server, with each tool earning its place across execution, process management, and diagnostics. No filler or redundant entries.
Covers command execution (normal, elevated, batch, PowerShell), process listing/cleanup, system info, and security rules—a solid lifecycle for the domain. Minor gaps: no targeted kill-by-PID or arbitrary background-process control beyond the age-based cleanup.
Maintenance
Related MCP Connectors
Execute PowerShell commands securely with controlled timeouts and input validation. Retrieve syste…
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Remote Desktop Commander: use files, terminal and processes on your own computers from any AI app.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables safe execution of terminal commands across different shells (bash, cmd, PowerShell) with configurable timeouts, working directories, and resource limits for command-line operations through AI assistants.-
- AlicenseAqualityCmaintenanceEnables secure command-line interactions on Windows systems with support for PowerShell, CMD, Git Bash, and WSL shells, providing controlled file access, command execution, and configurable security restrictions.620 npm4MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to safely perform file operations, run terminal sessions, manage processes, search content, and inspect Git repositories on a local Windows machine under configurable permission and audit controls.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to securely control a local Windows environment through guardrail-protected command execution, Python running, process and filesystem management, system monitoring, and desktop GUI automation. It uses layered security checks to validate commands, code, and paths before execution.MIT