windows-terminal-mcp
windows-terminal-mcp
一个 MCP (Model Context Protocol) 服务器,允许任何 LLM 在 Windows 终端上执行命令——包括本地 Shell 和远程 SSH 连接。
功能特性
通过
cmd、powershell或bash(Git Bash) 运行命令通过 SSH 使用基于密钥的身份验证执行远程命令
3 级安全模型(安全 / 确认 / 拦截)
可配置每个命令的超时时间
适用于 Claude Desktop 和任何兼容 MCP 的客户端
Related MCP server: Windows CLI MCP Server
安装
git clone https://github.com/marttinm/windows-terminal-mcp.git
cd windows-terminal-mcp
pip install -e .需要 Windows 上的 Python 3.11+。
配置
将服务器添加到您的 Claude Desktop 配置文件 (%APPDATA%\Claude\claude_desktop_config.json) 中:
{
"mcpServers": {
"windows-terminal": {
"command": "cmd",
"args": ["/c", "python", "-m", "windows_terminal_mcp.server"]
}
}
}或者直接指向脚本:
{
"mcpServers": {
"windows-terminal": {
"command": "cmd",
"args": ["/c", "python", "C:/path/to/windows-terminal-mcp/src/windows_terminal_mcp/server.py"]
}
}
}工具:execute_command
参数
参数 | 类型 | 默认值 | 描述 |
| string | 必填 | 要运行的命令。对于 SSH: |
| string |
| Shell 类型: |
| string | — | 工作目录(仅限本地命令) |
| integer |
| 超时时间(毫秒) |
| string | — | SSH 私钥路径(例如 |
响应
{
"stdout": "...",
"stderr": "...",
"exit_code": 0,
"execution_time": 0.42
}使用示例
本地命令
Run: dir C:\Users
Shell: cmd
Run: Get-Process | Select-Object -First 5
Shell: powershell
Run: git status
Shell: bashSSH 命令
Run: ubuntu@192.168.1.10 "df -h && uptime"
Shell: ssh
SSH key: ~/.ssh/id_rsaRun: ubuntu@192.168.1.10 "docker ps"
Shell: ssh
SSH key: ~/.ssh/my_key
Timeout: 30000安全性
命令分为三个级别:
安全 (Safe) — 直接执行echo、dir、type、git、npm、node、python、pip、curl 以及大多数只读命令。
危险 (Dangerous) — Claude 在执行前会发出警告del、rmdir、rm、taskkill、net stop、net start、sc delete、reg add 等。
拦截 (Blocked) — 始终拒绝format、del /s /q、rd /s /q、reg delete、regedit、shutdown、net user、rm -rf、mkfs、fdisk 以及类似的破坏性操作。
开发
项目结构
windows-terminal-mcp/
├── src/windows_terminal_mcp/
│ ├── __init__.py
│ ├── server.py # MCP server (main entry point)
│ ├── executor.py # subprocess execution
│ ├── main.py # simple stdin/stdout handler
│ └── security.py # command safety checks
├── tests/
│ └── test_windows_terminal_mcp.py
├── pyproject.toml
├── LICENSE
└── README.md运行测试
pip install pytest
pytest tests/ -v作为 Python 模块使用
from windows_terminal_mcp.server import execute_command
result = execute_command("echo hello", shell="cmd")
print(result)
# {'stdout': 'hello\n', 'stderr': '', 'exit_code': 0, 'execution_time': 0.02}
result = execute_command(
"ubuntu@192.168.1.10 uptime",
shell="ssh",
ssh_key="~/.ssh/id_rsa",
timeout_ms=10000,
)
print(result)更新日志
v0.2.0
增加了对基于密钥的 SSH 身份验证的支持
修复了 SSH 命令构建(主机和远程命令作为单独的参数传递)
修复了 Windows 上 SSH 密钥路径中
~的扩展问题修复了导致 SSH 在 MCP 服务器进程内挂起的 stdin 继承问题
v0.1.0
通过 cmd、powershell、bash 进行基本命令执行
stdout/stderr/exit_code 捕获
3 级安全模型
单元测试
许可证
MIT — 参见 LICENSE
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Related MCP Servers
- AlicenseAqualityFmaintenanceAn MCP server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface for LLMs.1034 PyPI97MIT
- AlicenseBqualityFmaintenanceA Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.9959 npm268MIT
- FlicenseAqualityDmaintenanceA local Model Context Protocol server that allows LLMs to securely execute shell commands on remote Linux and Windows systems via SSH connections.66 npm2-
- AlicenseBqualityAmaintenanceA secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.13264 npm6MIT