内容
<p align="center">
<img src="docs/banner.svg" alt="MCP Linux Desktop" width="700"/>
</p>
<p align="center">
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT License"/></a>
<img src="https://img.shields.io/badge/MCP-server-blue?style=flat-square" alt="MCP Server"/>
<img src="https://img.shields.io/badge/Linux-GNOME%20%7C%20X11-orange?style=flat-square&logo=linux&logoColor=white" alt="Linux"/>
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square&logo=node.js&logoColor=white" alt="Node 18+"/>
</p>
MCP 服务器,用于完全控制 Linux 桌面 — 窗口、鼠标、键盘、剪贴板、音频、截图、OCR、通知、辅助功能树和系统管理。与任何 MCP 兼容的 AI 代理一起使用。
## 安装
```bash
cd mcp-linux-desktop
npm install
```
添加到您的 MCP 配置:
```json
{
"mcpServers": {
"linux-desktop": {
"command": "node",
"args": ["/path/to/mcp-linux-desktop/server.js"]
}
}
}
```
## 工具
### 窗口管理
| 工具 | 描述 |
|------|-------------|
| `window_list` | 列出所有打开的窗口及其 ID、名称、几何形状 |
| `window_focus` | 通过 ID 或名称聚焦窗口 |
| `window_close` | 关闭窗口 |
| `window_minimize` | 最小化窗口 |
| `window_resize` | 调整窗口大小和/或移动窗口 |
### 鼠标和键盘
| 工具 | 描述 |
|------|-------------|
| `mouse_move` | 将光标移动到坐标 |
| `mouse_click` | 点击(左/右/中,单击/双击) |
| `mouse_scroll` | 在任意方向滚动 |
| `mouse_drag` | 从一个位置拖动到另一个位置 |
| `mouse_location` | 获取当前光标位置 |
| `keyboard_type` | 输入文本 |
| `keyboard_key` | 按键组合(例如 `ctrl+a`,`alt+Tab`) |
### 应用程序和文件
| 工具 | 描述 |
|------|-------------|
| `app_launch` | 通过名称或命令启动应用程序 |
| `app_list` | 列出正在运行的图形应用程序 |
| `file_open` | 使用默认应用程序打开文件或 URL |
### 剪贴板
| 工具 | 描述 |
|------|-------------|
| `clipboard_read` | 读取剪贴板内容 |
| `clipboard_write` | 将文本写入剪贴板 |
### 音频
| 工具 | 描述 |
|------|-------------|
| `volume_get` | 获取当前音量和静音状态 |
| `volume_set` | 设置音量(0-100)或切换静音 |
### 屏幕
| 工具 | 描述 |
|------|-------------|
| `screenshot` | 截图整个屏幕或区域 |
| `screen_observe` | 截图 + 屏幕元数据(分辨率、活动窗口、鼠标位置) |
| `ocr_screen` | 截图区域并通过 OCR 提取文本 |
### 无障碍
| 工具 | 描述 |
|------|-------------|
| `ui_elements` | 通过 AT-SPI 读取交互式 UI 元素(按钮、字段、菜单)及其屏幕坐标 |
### 系统
| 工具 | 描述 |
|------|-------------|
| `system_info` | CPU、RAM、磁盘、运行时间 |
| `process_list` | 列出进程(可选名称过滤) |
| `process_kill` | 通过 PID 或名称杀死进程 |
| `notify` | 发送桌面通知 |
| `brightness_get` | 获取屏幕亮度 |
| `dbus_call` | 调用 DBus 方法(GNOME shell、systemd 等) |
## 系统依赖
必需:
- **Node.js** 18+
- **xdotool** — 窗口/鼠标/键盘控制
- **xclip** — 剪贴板(X11)
- **Python 3** + **Pillow** — 截图
可选:
- **wl-paste / wl-copy** — Wayland 上的剪贴板
- **tesseract-ocr** + **tesseract-ocr-fra** — OCR
- **notify-send** — 桌面通知
- **wpctl** 或 **pactl** — 音频控制
- **gdbus** — DBus 调用
- **PyGObject** + **AT-SPI** — 无障碍树(`ui_elements`)
在 Ubuntu/Debian 上安装:
```bash
sudo apt install xdotool xclip python3-pil tesseract-ocr tesseract-ocr-fra \
libnotify-bin pipewire-pulse gir1.2-atspi-2.0
```
## 环境变量
| 变量 | 默认值 | 描述 |
|----------|---------|-------------|
| `DISPLAY` | `:1` | 要针对的 X11 显示 |