Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

README.md
# Windows 完全自动化 MCP 服务器

这是一个功能强大的 Windows 自动化 MCP 服务器,提供完整的 Windows 系统控制能力。

## 🎯 功能特性

### 1. 文件系统操作
- ✅ 读写文件
- ✅ 创建/删除/移动/复制文件
- ✅ 列出目录内容
- ✅ 搜索文件

### 2. 进程管理
- ✅ 启动应用程序
- ✅ 结束进程
- ✅ 列出进程
- ✅ 获取进程信息

### 3. 鼠标键盘控制
- ⚠️ 移动鼠标
- ⚠️ 鼠标点击
- ⚠️ 输入文本
- ⚠️ 按键模拟
- ⚠️ 获取鼠标位置
- ⚠️ 获取屏幕尺寸

> ⚠️ 注意:鼠标键盘功能需要 `robotjs`,需要 Windows Build Tools

### 4. 窗口管理
- ✅ 列出所有窗口
- ✅ 获取当前活动窗口
- ✅ 激活窗口
- ✅ 关闭窗口
- ✅ 最小化窗口

### 5. 屏幕截图
- ✅ 全屏截图
- ✅ 区域截图
- ✅ 自定义保存路径

### 6. 剪贴板操作
- ✅ 获取剪贴板内容
- ✅ 设置剪贴板内容
- ✅ 清空剪贴板

### 7. PowerShell/CMD
- ✅ 执行 PowerShell 命令
- ✅ 执行 CMD 命令
- ✅ 获取系统信息
- ✅ 获取磁盘信息
- ✅ 获取网络信息

### 8. 浏览器自动化
- ⚠️ 启动浏览器
- ⚠️ 导航到网页
- ⚠️ 点击元素
- ⚠️ 输入文本
- ⚠️ 截图
- ⚠️ 获取元素文本

> ⚠️ 注意:浏览器功能需要 `puppeteer`

## 📦 安装

### 1. 基础安装(必需)
```bash
cd windows-automation-mcp
npm install
```

### 2. 可选依赖

#### 鼠标键盘控制(robotjs)
```bash
# 需要先安装 Windows Build Tools
npm install --global windows-build-tools

# 然后安装 robotjs
npm install robotjs
```

#### 浏览器自动化(puppeteer)
```bash
npm install puppeteer
```

## 🚀 使用方法

### 1. 在 Cursor 中配置

在 Cursor 的 MCP 配置文件中添加:

```json
{
  "mcpServers": {
    "windows-automation": {
      "command": "node",
      "args": ["c:\\Users\\Administrator\\Desktop\\cursor工作盘\\windows-automation-mcp\\src\\server.js"]
    }
  }
}
```

### 2. 重启 Cursor

配置后重启 Cursor,MCP 服务器将自动启动。

## 📚 工具使用示例

### 文件操作
```
请帮我读取桌面上的 test.txt 文件
请在 D:\\temp 目录下创建一个名为 hello.txt 的文件,内容是 "Hello World"
请列出 C:\\Users 目录下的所有文件和文件夹
```

### 进程管理
```
请帮我打开记事本
请列出所有正在运行的 chrome 进程
请结束所有 notepad.exe 进程
```

### 窗口管理
```
请列出所有打开的窗口
请激活标题包含"记事本"的窗口
请关闭标题包含"Chrome"的窗口
```

### 屏幕截图
```
请截取当前屏幕并保存到桌面
请截取屏幕左上角 800x600 的区域
```

### 剪贴板
```
请获取当前剪贴板的内容
请将"Hello World"复制到剪贴板
```

### PowerShell
```
请执行 PowerShell 命令获取系统信息
请获取所有磁盘的使用情况
请获取当前的网络配置
```

### 浏览器自动化
```
请启动浏览器并访问 https://www.baidu.com
请在搜索框中输入"hello world"并点击搜索按钮
请截取当前网页的完整截图
```

## ⚠️ 注意事项

1. **权限要求**:某些操作可能需要管理员权限
2. **安全性**:请谨慎使用 PowerShell 和 CMD 执行功能
3. **依赖项**:部分功能需要额外安装依赖
4. **Windows 专用**:此 MCP 服务器仅支持 Windows 系统

## 🔧 故障排除

### robotjs 安装失败
```bash
# 1. 安装 Windows Build Tools
npm install --global windows-build-tools

# 2. 重新安装 robotjs
npm install robotjs
```

### puppeteer 下载失败
```bash
# 使用国内镜像
set PUPPETEER_DOWNLOAD_HOST=https://npmmirror.com/mirrors
npm install puppeteer
```

## 📝 工具列表

完整的工具列表:

**文件系统** (8 个工具)
- read_file, write_file, list_directory, create_directory
- delete_file, copy_file, move_file, search_files

**进程管理** (4 个工具)
- launch_application, kill_process, list_processes, get_process_info

**鼠标键盘** (6 个工具)
- move_mouse, mouse_click, type_text, press_key
- get_mouse_position, get_screen_size

**窗口管理** (6 个工具)
- list_windows, get_active_window, activate_window
- close_window, minimize_window, maximize_window

**屏幕截图** (2 个工具)
- take_screenshot, take_screenshot_region

**剪贴板** (3 个工具)
- get_clipboard, set_clipboard, clear_clipboard

**PowerShell** (5 个工具)
- run_powershell, run_cmd, get_system_info
- get_disk_info, get_network_info

**浏览器** (7 个工具)
- browser_launch, browser_navigate, browser_click
- browser_type, browser_screenshot, browser_get_text, browser_close

## 📄 许可证

MIT License

TDQS

C2.8/5.0

Scored across 41 tools

Disambiguation4/5

Most tools have distinct purposes targeting specific Windows automation tasks like window management, browser control, file operations, and system monitoring. However, some overlap exists: 'take_screenshot' and 'take_screenshot_region' are closely related, and 'browser_type' vs 'type_text' could cause confusion in web vs general input contexts. Descriptions help clarify, but minor ambiguity remains.

Naming Consistency5/5

Tool names follow a highly consistent verb_noun pattern throughout, using snake_case uniformly. Examples include 'activate_window', 'browser_click', 'copy_file', and 'get_system_info'. This predictability makes the set easy to navigate and understand at a glance.

Tool Count3/5

With 41 tools, the count feels heavy for a single server, potentially overwhelming for agents. While Windows automation is broad, many tools (e.g., 'get_mouse_position', 'move_mouse', 'mouse_click') could be consolidated into fewer, more general tools. It's borderline but leans toward excessive given the scope.

Completeness5/5

The tool surface comprehensively covers Windows automation domains: file management (CRUD operations), process control, window manipulation, browser automation, system monitoring, and input simulation. No obvious gaps are present; agents can perform end-to-end workflows without dead ends.