Skip to main content
Glama
dsh-desktop-mcp

dsh-desktop-mcp

by XeunwMu
README.md
# dsh-desktop-mcp

![dsh-desktop-mcp — Windows desktop control over MCP](docs/screenshot.svg)

**English** · [中文](#中文说明)

A small, self-contained **Windows desktop-control MCP server** for
[DeepSeek Harness (DSH)](https://github.com). It lets an agent *see* and *drive*
the local desktop over the Model Context Protocol (MCP) via **stdio**.

Once connected, the tools show up as `mcp__desktop__*`:

| Tool | What it does |
| --- | --- |
| `screen_info` | Screen size, monitor layout, cursor position |
| `screenshot` | Capture the screen (full / one monitor / a region) to a PNG |
| `cursor_position` | Current cursor position + screen size |
| `mouse_move` | Move the cursor to `(x, y)` |
| `mouse_click` / `mouse_double_click` | Click at `(x, y)` or the current position |
| `mouse_drag` | Press, drag from A to B, release |
| `mouse_scroll` | Scroll the wheel (positive = up) |
| `type_text` | Type / paste text at the current focus (Unicode-safe via clipboard) |
| `press_keys` | Press a key or hotkey, e.g. `enter`, `ctrl+c`, `alt+tab` |
| `list_windows` | List visible top-level windows |
| `activate_window` | Bring a window (by title substring) to the front |
| `clipboard_get` / `clipboard_set` | Read / write the clipboard |
| `open_path` | Open a file, folder or URL with the OS default app |
| `sleep` | Wait N seconds |

## Why

Most desktop-automation bridges assume a full Node/browser stack. This one is a
single ~280-line Python file with a handful of well-known dependencies, so it is
easy to audit and drop into any MCP client that can spawn a stdio server.

## Requirements

- Windows (uses `pyautogui`, `mss`, `pygetwindow`, `os.startfile`).
- Python 3.9+.
- An **interactive, unlocked** desktop session (screenshots and input injection
  need a real session; it will not work over a locked screen).

## Install (standalone)

```powershell
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
```

> `requirements.txt` pins `mcp<2` because `mcp` 2.x renamed `FastMCP` to
> `MCPServer`; this project targets the 1.x line.

Run the server (stdio):

```powershell
.\.venv\Scripts\python.exe server.py
```

Self-test (a few non-destructive checks — prints screen info, takes one
screenshot to the temp dir, counts windows):

```powershell
.\.venv\Scripts\python.exe server.py --selftest
```

## Use with DeepSeek Harness (as a bundle)

This repo can also be installed as a DSH bundle. `package.json` declares a
`dsh.bundle.patch` and `cordis.patch.yml` registers the MCP client row.

> **Important — replace `&lt;PROJECT_PATH&gt;`.** `cordis.patch.yml` ships with a
> literal placeholder. Before installing, replace **every** `&lt;PROJECT_PATH&gt;`
> with the absolute path of this checkout on your machine (Windows form uses
> backslashes). The path must point at the folder that contains `server.py`,
> and `.venv\Scripts\python.exe` must exist there (see the install step above).
>
> Example — if you cloned into `C:\Users\you\Desktop\dsh-desktop-mcp`, the row
> becomes:
>
> ```yaml
> command: 'C:\Users\you\Desktop\dsh-desktop-mcp\.venv\Scripts\python.exe'
> args:
>   - 'C:\Users\you\Desktop\dsh-desktop-mcp\server.py'
> cwd: 'C:\Users\you\Desktop\dsh-desktop-mcp'
> ```
>
> Then install the folder itself (not a package on npm) through DSH's plugin
> manager — point it at the checkout directory.

The resulting patch row looks like this (placeholders shown unexpanded):

```yaml
- insert:
    - id: dsh-desktop-mcp
      name: '@deepseek-ai/dsh-mcp-client'
      config:
        serverName: desktop
        transport: stdio
        command: '<PROJECT_PATH>\.venv\Scripts\python.exe'
        args:
          - '<PROJECT_PATH>\server.py'
        cwd: '<PROJECT_PATH>'
        failOnStartupError: true
        toolCallTimeoutMs: 120000
```

## Use with any other MCP client

Add a stdio server entry, e.g. for a typical JSON config:

```json
{
  "mcpServers": {
    "desktop": {
      "command": "C:\\path\\to\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\server.py"]
    }
  }
}
```

## Safety

- This grants **real control of your machine** — mouse, keyboard, clipboard,
  files. Only enable it when you trust the agent/session.
- `pyautogui` **FAILSAFE** is on: slam the mouse into a screen corner to abort.
- Some DSH setups run a "read-only external MCP" allow-list. To use the control
  tools you may need to add their names (e.g. `screen_info`, `screenshot`,
  `mouse_*`, `type_text`, ...) to `permissions.mcpReadOnlyTools`.

## 中文说明

一个用于 **DeepSeek Harness(DSH)** 及任意 MCP 客户端的 Windows 桌面控制 MCP 服务器:截图、鼠标、键盘、窗口、剪贴板,全部通过 **stdio** 接入。单文件 `server.py`、纯 Python,易于审计。

```powershell
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe server.py --selftest   # 自测:打印屏幕信息、截一张图、统计窗口数
```

作为 DSH bundle 安装时,记得把 `cordis.patch.yml` 里的 `&lt;PROJECT_PATH&gt;` 全部替换成本机检出的绝对路径。

## License

MIT — see [LICENSE](LICENSE).