Skip to main content
Glama
kitfactory

PyMCPAutoGUI

by kitfactory

PyMCPAutoGUI 🖱️⌨️🖼️ - 通过 MCP 进行 GUI 自动化

许可证:MIT

增强你的 AI 代理能力! ✨ PyMCPAutoGUI 在你的 AI 代理(例如 Cursor 或其他兼容 MCP 的环境中)和计算机的图形用户界面 (GUI) 之间架起了一座桥梁。它允许你的代理查看屏幕👁️、控制鼠标🖱️和键盘⌨️,并与窗口🪟交互,就像人类用户一样!

告别繁琐的手动 GUI 任务,让你的 AI 轻松搞定一切💪。非常适合自动化重复操作、测试 GUI 或构建强大的 AI 助手🤖。

🤔 为什么选择 PyMCPAutoGUI?

  • **🤖 增强您的代理的能力:**让您的 AI 代理能够直接与桌面应用程序交互。

  • **✅ 轻松集成:**与兼容 MCP 的客户端(例如 Cursor 编辑器)无缝协作。即插即用!

  • **🚀 易于使用:**只需一个简单的服务器命令即可开始使用。真的,就是这么简单。

  • **🖱️⌨️全面控制:**通过久经考验的PyAutoGUI和PyGetWindow提供广泛的 GUI 自动化功能。

  • **🖼️ 屏幕感知:**包括截取屏幕截图和在屏幕上定位图像的工具 - 让您的代理看到!

  • **🪟 窗口管理:**控制窗口位置、大小、状态(最小化、最大化)等。让桌面更整洁!

  • **💬 用户交互:**显示警报、确认和提示框以与用户进行交流。

Related MCP server: windows-computer-use-mcp

🛠️ 支持的环境

  • 操作系统: Windows、macOS、Linux(每个操作系统上都需要pyautogui的适当依赖项)

  • Python: 3.11+🐍

  • **MCP 客户端:**光标编辑器,任何支持模型上下文协议 (MCP) 的客户端

🚀 入门 - 超级简单!

1.安装(推荐:使用虚拟环境!)

使用虚拟环境可以使您的项目依赖关系保持整洁。

# Create and activate a virtual environment (example using venv)
python -m venv .venv
# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux bash
source .venv/bin/activate

# Install using pip (from PyPI or local source)
# Make sure your virtual environment is active!
pip install pymcpautogui # Or pip install . if installing from local source

(注意: pyautogui可能有系统依赖项,如 Linux 上的scrot用于截图。请查看pyautogui文档了解特定于操作系统的安装要求。)

2. 运行 MCP 服务器

安装完成后,只需从终端运行服务器:

# Make sure your virtual environment is activated!
python -m pymcpautogui.server

服务器将启动并监听连接(默认端口 6789)。查看以下输出:

INFO:     Started server process [XXXXX]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:6789 (Press CTRL+C to quit)

当你需要 GUI 自动化魔法时,请保持此终端运行!✨

✨ 与光标编辑器无缝集成

将 PyMCPAutoGUI 连接到 Cursor(@ 符号),以便在编码工作流程中直接实现 GUI 自动化。

  1. **打开 MCP 配置:**在 Cursor 中,使用命令面板( Ctrl+Shift+P或Cmd+Shift+P )并找到“MCP:打开 mcp.json 配置文件”。

  2. **添加 PyMCPAutoGUI 配置:**将此配置添加或合并到你的mcp.json中。如有需要,请调整路径(尤其是当 Cursor 未从项目根目录运行时)。

    {
        "mcpServers": {
            // ... other MCP server configs if any ...
            "PyMCPAutoGUI": {
                // Sets the working directory. ${workspaceFolder} is usually correct.
                "cwd": "${workspaceFolder}",
    
                // Command to run Python. 'python' works if the venv is active in the terminal
                // where Cursor was launched, or specify the full path.
                "command": "python", // Or ".venv/Scripts/python.exe" (Win) or ".venv/bin/python" (Mac/Linux)
    
                // Arguments to start the server module.
                "args": ["-m", "pymcpautogui.server"]
            }
            // ... other MCP server configs if any ...
        }
    }

    (提示:如果mcp.json已经存在,只需在mcpServers对象内添加"PyMCPAutoGUI": { ... }部分。)

  3. 保存mcp.json 。 Cursor 将检测服务器。

  4. **自动化!**在 Cursor 聊天中使用@PyMCPAutoGUI :

    例如: @PyMCPAutoGUI move_to(x=100, y=200)``@PyMCPAutoGUI write(text='Automating with AI! 🎉', interval=0.1)``@PyMCPAutoGUI screenshot(filename='current_screen.png')``@PyMCPAutoGUI activate_window(title='Notepad')

🧰 可用工具

PyMCPAutoGUI 公开了pyautogui和pygetwindow的大部分功能。示例包括:

  • 鼠标🖱️: move_to 、 click 、 move_rel 、 drag_to 、 drag_rel 、 scroll 、 mouse_down 、 mouse_up 、 get_position

  • 键盘⌨️: write , press , key_down , key_up , hotkey

  • 屏幕截图🖼️: screenshot 、 locate_on_screen 、 locate_center_on_screen

  • Windows 🪟: get_all_titles 、 get_windows_with_title 、 get_active_window``activate_window窗口、激活窗口、 minimize_window 、 maximize_window 、 restore_window 、 move_window 、 resize_window 、 close_window

  • 对话框💬: alert 、 confirm 、 prompt 、 password

  • 配置⚙️: set_pause 、 set_failsafe

有关完整列表和详细信息,请检查pymcpautogui/server.py文件或在 MCP 客户端中使用@PyMCPAutoGUI list_tools 。

📄 许可证

本项目采用 MIT 许可证 - 详情请参阅许可证文件。祝您自动化愉快!😄

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    GUI automation MCP server that enables AI agents to see and control the Windows desktop using a local Vision LLM (Ollama), supporting screenshot analysis, mouse/keyboard actions, and autonomous task execution.
    4
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that gives AI agents human-like control over Windows via visual perception and simulated mouse and keyboard input, enabling automation of any application without APIs.
    19 npm
    3
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    An MCP server that translates human GUI actions into machine-executable commands, enabling AI agents to control real software applications like Zoom, Excel, and WeChat via natural language or API calls.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A local, dependency-free MCP server that gives AI agents controlled access to the active Windows desktop, enabling automated interaction with applications through screenshots, clicks, typing, and window management.
    75 npm
    MIT