PyMCPAutoGUI

MIT License
  • Apple
  • Linux

Integrations

  • Supports GUI automation on Linux operating systems, allowing agents to interact with Linux desktop environments through mouse and keyboard control.

  • Supports GUI automation on macOS, enabling agents to control mouse movements, keyboard input, and interact with macOS desktop applications.

  • Enables installation of the PyMCPAutoGUI package via pip from PyPI, making it easy to set up the GUI automation server.

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

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

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

🤔 为什么选择 PyMCPAutoGUI?

  • **🤖 增强您的代理的能力:**让您的 AI 代理能够直接与桌面应用程序交互。
  • **✅ 轻松集成:**与兼容 MCP 的客户端(例如 Cursor 编辑器)无缝协作。即插即用!
  • **🚀 易于使用:**只需一个简单的服务器命令即可开始使用。真的,就是这么简单。
  • **🖱️⌨️全面控制:**通过久经考验的PyAutoGUIPyGetWindow提供广泛的 GUI 自动化功能。
  • **🖼️ 屏幕感知:**包括截取屏幕截图和在屏幕上定位图像的工具 - 让您的代理看到
  • **🪟 窗口管理:**控制窗口位置、大小、状态(最小化、最大化)等。让桌面更整洁!
  • **💬 用户交互:**显示警报、确认和提示框以与用户进行交流。

🛠️ 支持的环境

  • 操作系统: 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+PCmd+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 公开了pyautoguipygetwindow的大部分功能。示例包括:

  • 鼠标🖱️: move_toclickmove_reldrag_todrag_relscrollmouse_downmouse_upget_position
  • 键盘⌨️: writepresskey_downkey_uphotkey
  • 屏幕截图🖼️: screenshotlocate_on_screenlocate_center_on_screen
  • Windows 🪟: get_all_titlesget_windows_with_titleget_active_window``activate_window窗口、激活窗口、 minimize_windowmaximize_windowrestore_windowmove_windowresize_windowclose_window
  • 对话框💬: alertconfirmpromptpassword
  • 配置⚙️: set_pauseset_failsafe

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

📄 许可证

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

-
security - not tested
A
license - permissive license
-
quality - not tested

MCP 服务器将 AI 代理与 GUI 自动化功能连接起来,允许它们控制鼠标、键盘、窗口并截取屏幕截图以与桌面应用程序进行交互。

  1. 🤔 Why Choose PyMCPAutoGUI?
    1. 🛠️ Supported Environments
      1. 🚀 Getting Started - It's Super Easy!
        1. 1. Installation (Recommended: Use a Virtual Environment!)
        2. 2. Running the MCP Server
      2. ✨ Seamless Integration with Cursor Editor
        1. 🧰 Available Tools
          1. 📄 License
            ID: p5bs2wz5kz