Omni-Desktop-MCP
by yangdw2024
README.md
# Omni-Desktop-MCP
An [MCP](https://modelcontextprotocol.io) server that lets an AI agent observe and operate desktop applications through three stable tools.
> **Platform status**
>
> | Platform | Status |
> |---|---|
> | Windows 10/11 | Implemented and tested (see [Testing](#testing)). |
> | macOS | Experimental stub: window listing and screenshots only; input actions return `unsupported_on_current_host`. Not tested on macOS hardware. |
> | Linux | Experimental stub using `wmctrl`/`xdotool` when present. Not tested on a Linux desktop. |
>
> This is alpha software (0.1.0). It can click, type, and close windows on your machine. Read [Safety](#safety) first.
## What it does
- **Three tools** (a small, fixed tool list keeps prompts and caches stable): `desktop_observe`, `desktop_act`, `desktop_status`.
- **Compact UI Automation tree** with one line per interactive control, plus `diff=true` to return only added (`+`), changed (`~`), and removed (`-`) controls since the last observation of that window.
- **OCR on Windows** through the built-in WinRT OCR engine (Chinese and English language packs, whichever are installed), mapped back to screen coordinates, as a fallback for UIs that expose no accessibility tree.
- **Background-first input**: `desktop_act` tries UIA patterns (Invoke, Value, Toggle, SelectionItem, ExpandCollapse, Scroll) first, which move no cursor and change no focus. If that is unavailable it falls back to foreground `SendInput`, then to a foreground-lock workaround, and restores the previous foreground window by default.
- **Unicode-safe typing**: UIA ValuePattern with read-back verification, otherwise Unicode `SendInput`, or a clipboard paste that restores the previous clipboard text.
- **Guardrails**: stale-snapshot rejection, a 5 s repeat suppressor, a blocklist of dangerous hotkeys, and protection against closing system and harness windows.
## Install
```powershell
pip install omni-desktop-mcp
```
Requires Python 3.10+ and `mcp` 2.x (installed automatically). Windows dependencies (`pywin32`, `uiautomation`) are installed automatically on Windows.
Run it directly:
```powershell
omni-desktop-mcp # stdio
omni-desktop-mcp --http --host 127.0.0.1 --port 8765 # Streamable HTTP
```
### Register with your clients
Preview which config files would change (nothing is written):
```powershell
omni-desktop-mcp-install
```
Apply (existing files are backed up to `*.bak-<timestamp>` first; a file that fails to parse is left alone):
```powershell
omni-desktop-mcp-install --apply
omni-desktop-mcp-install --apply --only codex,trae
```
It knows about Antigravity (`~/.gemini`), Codex (`~/.codex/config.toml`), and Trae CN, only touches clients whose config directory already exists, and also installs the bundled usage skill for DeepSeek Harness, Codex, and Trae CN where a skills directory exists.
Or add it by hand. Generic snippets are in [`clients/doubao-mcp.json`](clients/doubao-mcp.json), for example:
```json
{
"mcpServers": {
"omni-desktop": {
"command": "python",
"args": ["-m", "omni_desktop_mcp"],
"env": { "PYTHONIOENCODING": "utf-8" }
}
}
}
```
If `python` on your PATH is not the one you installed into, use the absolute path to that `python.exe`.
**DeepSeek Harness**: the repository root is also a configuration-only DSH bundle (`package.json` with `dsh.bundle`, plus `cordis.patch.yml`) that mounts the server through DSH's built-in MCP client. It does not ship the Python server itself, so run `pip install omni-desktop-mcp` first. The bundle launches `python -m omni_desktop_mcp`, so `python` on DSH's PATH must be the one you installed into; if it is not, set `command` to the absolute path of that `python.exe`. This bundle has been exercised only in the form below with an absolute Python path; resolving a bare `python` from a clean DSH profile has not been verified yet. The equivalent patch row is:
```yaml
- insert:
- id: omni-desktop-mcp
name: '@deepseek-ai/dsh-mcp-client'
config:
serverName: desktop
transport: stdio
command: C:\path\to\python.exe
args: [-m, omni_desktop_mcp]
env: { PYTHONIOENCODING: utf-8 }
toolCallTimeoutMs: 120000
startupTimeoutMs: 25000
failOnStartupError: false
```
## Tools
- `desktop_observe(mode, window, diff, max_elements, ocr_lang, include_image, annotate, region)`: `mode` is `windows`, `tree`, `ocr`, `screenshot`, or `hybrid`. If `tree` finds no interactive controls it automatically adds OCR. Images are capped at 1920x1080.
- `desktop_act(action, target, window, snapshot_id, delivery, ...)`: `click`, `double_click`, `right_click`, `move`, `drag`, `scroll`, `type`, `press_key`, `hotkey`, `window_focus`, `window_state`, `launch_app`, `wait_for`, `batch`. `target` is a ref such as `w1:e3` / `w1:o2` from the latest observation, or `{x, y}` in physical screen pixels.
- `desktop_status(command)`: `health`, `policy`, `reset_guard`, `clear_snapshots`.
## Safety
This is not a sandbox. Anything the logged-in user can do with mouse and keyboard, an agent connected to this server can do.
- Dangerous hotkeys (`Ctrl+Alt+Del`, `Win+L`, `Shift+Del`, `Alt+F4`) and closing protected windows are refused unless `allow_dangerous=true` is passed. Treat that flag as something a human grants, not something an agent decides.
- Holding `Esc` aborts the current action; the key is polled at dispatch and between batch/drag steps, not inside a single OS call. No global input hooks are installed.
- The HTTP transport has **no authentication**. Keep it on `127.0.0.1`. Do not expose it to a network.
- Windows UIPI: a non-elevated server cannot drive an elevated window; such actions fail with `foreground_unavailable` rather than reporting success.
- Screenshots and OCR text can contain secrets that are on screen. They are returned to the connected client.
## Known limitations
- OCR is imperfect (for example `CLICKED` was read as `CL℃KED` in our own test). Do not rely on a single exact OCR string to confirm an action.
- Coordinates are physical screen pixels. The process declares Per-Monitor DPI v2 awareness; behaviour on unusual multi-monitor layouts has only been checked on one two-monitor machine.
- UIA tree walks are time-limited (2 s) and breadth-first with a node cap, so very large trees come back truncated and flagged.
- No latency or accuracy benchmarks against other desktop-automation servers have been run, so none are claimed.
## Testing
```powershell
pip install pytest
pytest
```
The unit tests cover snapshot diffing, stale refs, and the safety guard. `tests/test_windows_e2e.py` launches a temporary Tk window and drives it through observe, type, OCR, click, and screenshot; it needs an interactive Windows desktop and will briefly take foreground focus.
## License
MIT. See [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessNo recent community issues