๐ŸชŸ Windows MCP Server

August 28, 2026 ยท View on GitHub

License .NET Platform CI LLM Tests

Windows automation that actually works. Uses the Windows UI Automation API to find buttons by name, not pixels. Tested with real AI models through a dedicated manual workflow.

Why This Exists

Screenshot-based automation doesn't work reliably. Vision models guess wrong, coordinates break when windows move or DPI changes, and you burn through thousands of tokens on retry loops. We tried it (check the commit history) โ€” it failed too often to be useful.

Windows MCP Server asks Windows directly: "What buttons exist in this window?" Windows knows. It's deterministic.

How It Works

# 1. Find the window
window_management(action='find', title='Notepad') โ†’ handle='123456'

# 2. Click elements by name
ui_click(windowHandle='123456', nameContains='Save')

# 3. Type into fields
ui_type(windowHandle='123456', controlType='Edit', text='Hello World')

# 4. Fallback for games/canvas โ€” screenshot + mouse
screenshot_control(target='window', windowHandle='123456') โ†’ element coordinates
mouse_control(action='click', x=450, y=300)

Same command works every time. Any machine. Any DPI. Any theme.

Browsers follow the same semantic flow: launch msedge.exe or chrome.exe, then use ui_find, ui_click, and ui_type on links, buttons, and fields exposed through UIA names and ARIA labels.

Key Features

  • ๐Ÿง  Semantic UI โ€” Find elements by name, not coordinates. Works regardless of DPI, theme, or window position.
  • ๏ฟฝ Multi-Monitor โ€” Full support for multiple displays with per-monitor DPI scaling.
  • ๐Ÿงช LLM-Tested โ€” 130+ tests with a real AI model (GPT-5.5 via GitHub Copilot), run intentionally through a dedicated manual workflow.
  • ๐Ÿ’ป Broad App Support โ€” Tested against classic Windows apps, modern Windows 11 apps, and Electron apps (VS Code, Teams, Slack). Chromium browser pages follow the same ARIA-driven pattern, but browser chrome remains best-effort.
  • ๐Ÿ”„ Full Fallback โ€” Screenshot + mouse + keyboard for games and custom controls.
  • ๐Ÿช™ Token Optimized โ€” Short property names, JPEG screenshots, and auto-scaling substantially reduce token usage compared to standard JSON.

Installation

VS Code Extension โ€” Install from Marketplace. Works with GitHub Copilot automatically.

Plugin (GitHub Copilot CLI / Claude Code) โ€” Install the shared plugin bundle in plugin/:

copilot plugin install sbroenne/mcp-windows:plugin

For local Claude Code development:

claude --plugin-dir .\plugin

On first use, the plugin downloads the current standalone release into plugin\bin\.

Standalone โ€” Download from Releases. Add to your MCP config:

{ "servers": { "windows": { "command": "path\\to\\Sbroenne.WindowsMcp.exe" } } }

Limiting the exposed tools (optional) โ€” for a least-privilege setup, pass an allowlist or denylist on the server command line (or via environment variables). CLI flags take precedence over the env vars.

{ "servers": { "windows": {
  "command": "path\\to\\Sbroenne.WindowsMcp.exe",
  "args": ["--tools", "ui_snapshot,ui_find,ui_click,ui_type,ui_read"]
} } }
  • --tools <a,b,c> / WINDOWS_MCP_TOOLS โ€” expose only these tools.
  • --exclude-tools <x,y> / WINDOWS_MCP_EXCLUDE_TOOLS โ€” expose everything except these.

Excluded tools never appear in tools/list and cannot be invoked.

Tools

ToolPurpose
ui_snapshotCapture a compact element tree; mode=auto returns smaller updates after the first view
ui_findDiscover elements in a window (with timeout/retry)
ui_clickClick buttons, checkboxes, menu items by name
ui_typeType into text fields
ui_selectPick a value in a combo box, list, or tab
ui_readRead text from elements (with OCR fallback)
ui_read_tableExtract a grid/table/list-view into structured rows + headers
ui_waitWait for an element to appear, disappear, or reach a state
ui_batchRun several UI steps (find/click/type/select/wait/read/snapshot/key/mouse/polyline) in one call
ui_macroRecord & replay a ui_batch sequence by name (save/run/list/get/delete)
file_saveSave files via Save As dialog
file_openOpen an existing file via the Open dialog
clipboardRead/write the Windows text clipboard (get/set/clear)
processList or kill running processes, task-manager style (list/kill)
screenshot_controlGet element metadata (image optional)
window_managementFind, activate, move, resize windows
mouse_controlCoordinate-based clicks (fallback for games)
keyboard_controlHotkeys and key sequences
appLaunch applications

Full reference: FEATURES.md

Use the default mode=full for one inspection. For repeated views of the same window or a known subtree through the long-running MCP server, use mode=auto from the first view; full is not remembered. The first response has kind=full; later responses have kind=diff when a short change list saves space, otherwise they safely fall back to kind=full. Use mode=reset to start a new comparison, and use parentElementId only to revisit a subtree returned by an earlier snapshot or find. Separate wincli commands do not share remembered views. The reproducible benchmark measured 84-96% median byte/token savings in Electron, Word, and Excel. A Playwright-style semantic view improved realistic Chrome navigation to 13.1% fewer bytes and 13.4% fewer approximate tokens even though 18 of 20 responses were complete simplified views. A later strict Chrome run found that conservative display cleanup alone removed another 10.6% of bytes and 13.6% of tokens from automatic responses.

Snapshot response compatibility: complete snapshots still return the compact tree, but no longer repeat the same hierarchy in the former full-detail elements field. Consumers that read that undocumented duplicate should migrate to tree (or use ui_find for a flat result).

Command-line interface (wincli)

The server ships with a twin command-line entry point, wincli, in src/Sbroenne.WindowsMcp.Cli. It exposes the exact same capabilities as the MCP server โ€” every command calls the same underlying tool, so the JSON output is byte-for-byte identical to the MCP tools (verified by a parity test).

wincli is the token-efficient path for coding agents: instead of loading every MCP tool schema into context, an agent with shell access discovers the whole surface through --help / tools / guidance and issues one command per action. Because window handles are OS-global, each call is stateless โ€” there is no server session to keep alive.

wincli window find --title Notepad           # -> window handle
wincli ui snapshot --window 12345 --mode full  # complete accessible element tree
wincli ui click --window 12345 --name Submit --with-snapshot
wincli clipboard set --text "hello"          # write the clipboard
wincli macro run --name login --window 12345 # replay a saved workflow
wincli guidance                              # full automation guide

Exit codes: 0 success, 1 tool error, 2 usage error. See the CLI README for the full command reference.

โš ๏ธ Caution

This MCP server controls your Windows desktop. Use responsibly.

Known Limitations

UAC & Elevated Processes โ€” Windows security prevents any non-elevated process from interacting with UAC prompts or elevated (Administrator) windows. This is a fundamental Windows security boundary, not an MCP limitation.

ScenarioWhat HappensWorkaround
winget install triggers UACAI cannot click the UAC promptRun terminal as Administrator first
App running as AdministratorUI automation tools return ElevatedWindowActive errorRun MCP server elevated, or use the app non-elevated
UAC prompt appearsAI cannot interact with secure desktopUser must manually approve

See FEATURES.md for details.

Testing

dotnet test                                      # All tests
dotnet test --filter "FullyQualifiedName~Unit"   # Unit only

Framework coverage: Tests run against WinForms, WinUI 3, Electron apps, and real Chromium browser app windows by default. The Chromium smoke stack now exercises both Edge and Chrome (when installed) across a deterministic local page and a required public-web slice (demo.playwright.dev/todomvc) using the same semantic-first UI Automation model with isolated browser state and browser-window-only cleanup.

dotnet test .\tests\Sbroenne.WindowsMcp.Tests\Sbroenne.WindowsMcp.Tests.csproj --filter "FullyQualifiedName~ChromiumBrowser"

LLM tests: 130+ tests with a real AI model (GPT-5.5 via GitHub Copilot). They are intentionally manual-only and never run as part of PR, CI, or release workflows. Run them from the dedicated LLM Integration Tests workflow in GitHub Actions.

cd tests/Sbroenne.WindowsMcp.LLM.Tests
uv run pytest -v

Requires GitHub authentication (GITHUB_TOKEN or an existing gh login) and a Windows desktop session. See LLM Tests README.

Documentation

DocumentDescription
FEATURES.mdComplete tool reference โ€” all actions, parameters, examples
Incremental snapshot benchmarkFive-run Electron, Chrome, Word, and Excel measurements
CONTRIBUTING.mdBuild instructions, coding guidelines, PR process
LLM Tests READMEHow to run LLM integration tests
Release SetupAzure OIDC and GitHub Actions configuration

License

MIT โ€” see LICENSE

Contributing

See CONTRIBUTING.md