Skip to main content
Glama
Windows-MCP for Antigravity

Windows-MCP for Antigravity

by Shaa-Yyu

Windows-MCP for Antigravity 基于上游开源项目 CursorTouch/Windows-MCP(v0.8.5,MIT 协议),针对 Google Antigravity 的工具体系、多模态上下文开销、插件自动发现机制与中文 Windows 桌面环境进行了系统性的工程优化与 Bug 修复。

它同时提供:

  • 优化版 MCP 服务器(支持 --profile antigravity / desktop-only / full、紧凑 JPEG 截图、零启动睡眠、stdio 纯净度保护、中文/CJK 防输入法乱码自动粘贴等)

  • 原生 Antigravity 插件包(plugin/:包含 plugin.json、mcp_config.json、rules/AGENTS.md、skills/windows-desktop-automation/SKILL.md 与矢量图标)

  • 一键安装 / 卸载 / 诊断 / 握手自检脚本(开箱即用,无需手写复杂 PYTHONPATH 或 JSON)


相比上游 Windows-MCP 0.8.5 的核心优化

1. 针对 Antigravity 的架构级集成

  • 原生 Antigravity 插件封装(plugin/):一次安装即可同时提供 MCP 服务器、工具边界规则(rules/AGENTS.md)与渐进式加载技能(skills/windows-desktop-automation/SKILL.md),可在 Antigravity 的 Customizations / Plugins 面板一键启停。

  • 防工具重叠的 Profile 预设(--profile antigravity):

    • Antigravity 原生已具备 run_command、read_file/write_file/edit_file、search_web 和 browser 子代理。

    • 上游默认暴露 PowerShell、FileSystem、Scrape,容易导致模型选错工具并白白消耗上下文 Token。

    • --profile antigravity 默认排除这 3 个重叠工具,精准保留 17 个原生 Windows 桌面与系统工具(如需完整 20 个工具,随时切换 --profile full)。

  • Antigravity 专属 CLI 子命令:

    • windows-mcp doctor:一键检测 Python、pywin32/COM/UIA、截图后端、显示器与 DPI、Antigravity 插件及全局配置冲突。

    • windows-mcp antigravity-config:自动生成可直接粘贴的 Antigravity mcp_config.json。

2. 性能与多模态 Token 优化

  • 移除硬编码启动延迟:移除上游 lifespan 中无条件的 await asyncio.sleep(1),改为可配置的 WINDOWS_MCP_STARTUP_DELAY(默认 0),显著加快 stdio 握手速度。

  • 紧凑截图编码(JPEG / WebP / 优化 PNG):新增 WINDOWS_MCP_IMAGE_FORMAT(antigravity 预设默认 jpeg)、WINDOWS_MCP_IMAGE_QUALITY(默认 85)以及 WINDOWS_MCP_MAX_IMAGE_WIDTH / WINDOWS_MCP_MAX_IMAGE_HEIGHT,相比无压缩 PNG 体积可降低 5–10 倍,大幅减少 stdio 传输耗时与多模态负载。

  • 向量化截图边框渲染 + 默认静默:

    • 修复上游 flash_overlay.py 用纯 Python 循环逐像素遍历 200 万像素(每次截图最多跑 32 帧、导致 CPU 飙升)的性能瓶颈,改为 NumPy 向量化实现(提速约 100 倍)。

    • antigravity 预设默认设置 WINDOWS_MCP_DISABLE_FLASH=1(可随时设回 0 开启)。

  • 默认关闭遥测:antigravity 预设默认 ANONYMIZED_TELEMETRY=false,并对 PostHog 初始化做了防御性异常隔离,离线/受限网络下不会阻塞或报错。

3. 稳定性与中文 Windows 关键 Bug 修复

  • 修复 Windows 剪贴板句柄泄漏(Critical):修复 uia/core.py 中 GetClipboardText() 在剪贴板为图片/文件等非文本格式时未调用 CloseClipboard() 导致整个系统剪贴板锁死的严重 Bug。

  • 中文 / CJK 输入防乱码:优化 Desktop.type(),任何包含非 ASCII(如中文、日文、韩文、Emoji)且不含控制字符的短文本均自动走剪贴板粘贴并恢复原剪贴板内容,彻底避开微软拼音等 IME 组合态丢字/乱码问题。

  • 修复 Scroll 工具返回值运算符优先级 Bug:修复 tools/input.py 中 loc=None 时返回空字符串 "" 的缺陷。

  • 修复 Click 三击及以上描述 Bug:修复 clicks >= 3 时返回 "None left clicked..." 的问题,现支持 Triple / Nx。

  • 修复 Snapshot 参数文档拼写不一致:修正工具描述中的 width_reference_lines/height_reference_lines 与实际参数名 width_reference_line/height_reference_line 不匹配的问题,避免模型传参触发 schema 校验报错。

  • 修复 PIL.ImageDraw 多线程绘制竞争:将 get_annotated_screenshot 中对非线程安全 ImageDraw 对象的并发调用改为确定性顺序绘制。

  • 修复 App(mode="resize") 首次调用失败:当未指定窗口名且缓存为空时自动查询当前前台窗口。

  • 增强 Clipboard 并发重试与 Notification 默认 AUMID:剪贴板打开增加短暂重试避免偶发 Access is denied;Notification 的 app_id 改为可选并内置 Windows PowerShell 系统 AUMID,开箱即可弹窗通知。

  • Stdio 纯净度保护与零配置启动器:scripts/run_server.py 自动配置 UTF-8、屏蔽导入期第三方库对 stdout 的意外输出,并兼容标准虚拟环境、uv 以及离线 vendor/ 目录(自动处理 pywin32_system32 DLL 搜索路径)。


Related MCP server: Windows-MCP

工具预设对比(Profiles)

Profile

暴露工具数

排除的工具

适用场景

antigravity(默认推荐)

17

PowerShell, FileSystem, Scrape

与 Antigravity 原生终端、文件、浏览器工具协同,省 Token、无冲突

desktop-only

14

PowerShell, FileSystem, Scrape, Process, Registry, Notification

仅需纯桌面视觉/键鼠/窗口/剪贴板自动化,最小权限面

full

20

无

与上游 Windows-MCP 100% 行为一致的全量模式

  • 视觉与感知:Screenshot、Snapshot、DisplayInventory

  • 窗口与应用:App(支持 launch / launch_executable / resize / switch)

  • 键鼠与批量操作:Click、Type、Scroll、Move、Shortcut、MultiSelect、MultiEdit

  • 等待同步:Wait、WaitFor(text_exists / active_window / element_exists / element_enabled / focused_element)

  • 系统工具:Clipboard、Process、Notification、Registry


快速开始

环境要求

  • Windows 10 / 11

  • Python 3.12+(推荐同时安装 uv 或使用 venv + pip)

  • Google Antigravity(Desktop / IDE / CLI)

第一步:克隆并安装依赖

方式 A:使用 uv(推荐)

git clone https://github.com/Shaa-Yyu/Windows-MCP-Antigravity.git
cd Windows-MCP-Antigravity
uv sync

方式 B:使用标准 Python venv + pip

git clone https://github.com/Shaa-Yyu/Windows-MCP-Antigravity.git
cd Windows-MCP-Antigravity
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .

第二步:一键安装并启用到 Antigravity

双击 install.bat,或在 PowerShell 中运行:

# 推荐:安装为 Antigravity 原生插件(自动包含 MCP Server + 规则 + 技能)
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1

# 若使用 uv 管理环境:
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -UseUv

# 可选:切换为纯 GUI 最小权限模式(desktop-only)或全量模式(full)
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -Profile desktop-only

# 可选:仅写入全局 ~/.gemini/config/mcp_config.json(不安装插件规则和技能)
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -Mode global-mcp

安装脚本会自动完成:

  1. 执行只读的 MCP stdio 握手自检(initialize + tools/list),确认环境正常;

  2. 将原生插件部署到 %USERPROFILE%\.gemini\config\plugins\windows-mcp\,并写入已解析好的本地路径配置;

  3. Antigravity 会自动发现并默认启用该插件,你可以随时在 Plugins / Customizations 面板中查看状态或一键开关。

手动配置(~/.gemini/config/mcp_config.json)

如果你希望手动配置而不使用插件模式,可以运行内置生成器:

python scripts\run_server.py antigravity-config

输出示例:

{
  "mcpServers": {
    "windows-mcp": {
      "command": "C:\\Path\\To\\Python312\\python.exe",
      "args": [
        "C:\\Path\\To\\windows-mcp-antigravity\\scripts\\run_server.py",
        "serve",
        "--profile",
        "antigravity"
      ],
      "env": {
        "ANONYMIZED_TELEMETRY": "false",
        "WINDOWS_MCP_PROFILE": "antigravity",
        "WINDOWS_MCP_DISABLE_FLASH": "1",
        "WINDOWS_MCP_IMAGE_FORMAT": "jpeg",
        "WINDOWS_MCP_IMAGE_QUALITY": "85",
        "PYTHONUTF8": "1",
        "PYTHONIOENCODING": "utf-8"
      }
    }
  }
}

注意:请勿同时在全局 mcp_config.json 与插件 plugins/windows-mcp/mcp_config.json 中重复注册同名的 windows-mcp,以免产生 MCP 服务器名称冲突。


自检、测试与卸载

# 1. 运行环境与 Antigravity 集成诊断
python scripts\run_server.py doctor

# 2. 运行只读 MCP stdio 握手测试(不触发任何桌面操作)
python scripts\probe_handshake.py --profile antigravity

# 3. 运行单元测试
python -m unittest discover -s tests -v

# 4. 卸载(自动清理插件目录及全局 mcp_config.json 中的对应条目)
.\uninstall.bat

常用环境变量

变量名

antigravity 默认值

说明

WINDOWS_MCP_PROFILE

antigravity

工具预设:antigravity / desktop-only / full

WINDOWS_MCP_IMAGE_FORMAT

jpeg

截图编码格式:jpeg、png、webp

WINDOWS_MCP_IMAGE_QUALITY

85

JPEG/WebP 压缩质量(1–100)

WINDOWS_MCP_MAX_IMAGE_WIDTH

1920

截图最大宽度(超出等比缩放并在元数据给出坐标倍率)

WINDOWS_MCP_MAX_IMAGE_HEIGHT

1080

截图最大高度

WINDOWS_MCP_SCREENSHOT_SCALE

1.0

额外缩放倍率(0.1–1.0),4K 屏建议 0.5–0.75

WINDOWS_MCP_SCREENSHOT_BACKEND

auto

截图后端:auto(dxcam → mss → pillow)、dxcam、mss、pillow

WINDOWS_MCP_DISABLE_FLASH

1

设为 1 关闭截图后的橙红色屏幕闪烁边框

WINDOWS_MCP_STARTUP_DELAY

0

启动延迟秒数(默认 0 秒极速启动)

WINDOWS_MCP_WATCHDOG

true

设为 off 关闭后台 UIA 焦点监听线程(休眠唤醒后若 UIA 卡顿可关闭)

WINDOWS_MCP_MAX_TREE_ELEMENTS

500

单次 Snapshot UIA 树最大遍历元素数

WINDOWS_MCP_NOTIFICATION_APP_ID

PowerShell AUMID

自定义 Toast 通知的 Windows AUMID

ANONYMIZED_TELEMETRY

false

设为 false 禁用 PostHog 遥测


仓库目录结构

windows-mcp-antigravity/
├── src/windows_mcp/            # 优化后的 Windows-MCP 核心源码
│   ├── _bootstrap.py           # UTF-8 stdio 守护与可选本地 vendor/pywin32 引导
│   ├── antigravity.py          # Profile 预设、配置生成与 doctor 诊断
│   ├── __main__.py             # CLI 入口(serve / doctor / antigravity-config / auth / install)
│   ├── desktop/                # 截图、标注、CJK 自动粘贴与向量化 overlay
│   ├── tools/                  # MCP 工具定义与紧凑图像编码
│   ├── uia/                    # UIAutomation 封装(已修复剪贴板句柄泄漏)
│   └── ...                     # tree / watchdog / vdm / process / registry / notifications
├── plugin/                     # Antigravity 原生插件模板
│   ├── plugin.json             # 插件清单
│   ├── mcp_config.json         # MCP 服务器配置模板
│   ├── assets/logo.svg         # 插件图标
│   ├── rules/AGENTS.md         # Antigravity 工具边界与安全准则
│   └── skills/windows-desktop-automation/SKILL.md
├── scripts/
│   ├── run_server.py           # 零配置 stdio 启动器
│   ├── probe_handshake.py      # 只读 MCP 握手自检脚本
│   ├── install.ps1             # 一键安装脚本(支持 plugin / global-mcp)
│   └── uninstall.ps1           # 一键卸载脚本
├── tests/                      # 优化与 Bug 修复验证测试
├── install.bat / uninstall.bat # Windows 双击脚本入口
├── pyproject.toml
├── CHANGELOG.md
└── LICENSE

安全提示

  • windows-mcp 拥有你当前 Windows 桌面账号同等的 GUI 操作权限(截图、模拟键鼠、管理窗口、读写剪贴板、结束进程、读写注册表)。

  • 建议日常使用 --profile antigravity 或 --profile desktop-only,并结合内置的 rules/AGENTS.md 安全准则,在执行不可逆操作前进行人工确认。

  • 本项目默认禁用遥测(ANONYMIZED_TELEMETRY=false),不会上传任何截图、参数或个人数据。

致谢与开源协议

本项目基于 CursorTouch/Windows-MCP(Copyright © 2025 JEOMON GEORGE)进行二次开发与 Antigravity 深度适配,遵循 MIT License,详见 LICENSE。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to interact with Windows operating systems through native UI automation, file navigation, application control, and system commands. Provides seamless integration between LLMs and Windows environments for tasks like clicking, typing, launching apps, and capturing desktop state.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with Windows operating systems by providing tools for UI automation, file navigation, application control, and system operations. Works with any LLM to perform tasks like clicking, typing, launching applications, and executing PowerShell commands through native Windows integration.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables comprehensive Windows desktop automation including screen capture, OCR text extraction, mouse/keyboard control, window management, process control, and clipboard operations through 25+ tools for AI agents.
      38 PyPI
      8
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to drive Windows desktop automation — opening and interacting with applications, native UI controls, keyboard/mouse input, files, processes, clipboard, and Chrome/Edge browsing via UI Automation and CDP. All actions pass through a safety policy with human approval, emergency stop, and deterministic verification.
      1
      MIT