Skip to main content

OmniParser MCP Server

License: MIT Python 3.10+ MCP

一個基於Microsoft OmniParser模型的MCP (Model Context Protocol) Server,用於UI自動化和屏幕解析。

🌟 功能特性

  • 🖥️ 屏幕截圖解析: 使用OmniParser模型解析UI截圖,識別可交互元素
  • 🖱️ 鍵鼠模擬: 支持鍵盤和滑鼠操作模擬
  • 🪟 視窗管理: 連接和管理特定應用程式視窗
  • 🌐 多平台支持: 支持桌面應用、瀏覽器和遊戲
  • 🔧 MCP協議: 完全兼容MCP協議,可與支持MCP的AI助手集成

📋 系統要求

  • Python 3.10+
  • Windows 10/11 (推薦,完整功能支持)
  • CUDA支持的GPU (推薦)
  • 8GB+ RAM
  • 5GB+ 可用磁盤空間

🚀 快速開始

1. 克隆項目

git clone https://github.com/yourusername/omniparser-mcp-server.git
cd omniparser-mcp-server

2. 安裝依賴

# 創建虛擬環境 (推薦)
python -m venv venv
source venv/bin/activate  # Linux/Mac
# 或 venv\Scripts\activate  # Windows

# 安裝依賴
pip install -r requirements.txt
pip install -e .

# Windows 用戶需要額外安裝
pip install pywin32 psutil

3. 下載OmniParser模型

# 下載模型權重 (需要先安裝 huggingface-cli)
pip install huggingface_hub

# 下載到 weights 目錄
mkdir -p weights
for f in icon_detect/{train_args.yaml,model.pt,model.yaml} icon_caption/{config.json,generation_config.json,model.safetensors}; do
    huggingface-cli download microsoft/OmniParser-v2.0 "$f" --local-dir weights
done
mv weights/icon_caption weights/icon_caption_florence

4. 配置設定

編輯 config.json 確保模型路徑正確,然後啟動服務器:

omniparser-mcp-server

🔧 MCP 配置

安裝MCP服務器

# 使用 uvx 安裝(推薦)
uvx install mcp-server-omniparser

# 或從源碼安裝
uvx install git+https://github.com/win10ogod/omniparser-mcp-server.git

Claude Desktop 配置

在 Claude Desktop 配置文件中添加:

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

基本配置:

{
  "mcpServers": {
    "omniparser": {
      "command": "uvx",
      "args": [
        "mcp-server-omniparser"
      ]
    }
  }
}

服務器配置

創建 config.json 文件來配置服務器行為:

{
    "omniparser": {
        "som_model_path": "weights/icon_detect/model.pt",
        "caption_model_name": "florence2",
        "caption_model_path": "weights/icon_caption_florence",
        "box_threshold": 0.05
    },
    "automation": {
        "screenshot_delay": 0.1,
        "action_delay": 0.5
    }
}

更多配置選項請參考 mcp_config_examples.json 文件。

MCP工具

屏幕解析工具

  • parse_screen: 解析當前屏幕或指定視窗
  • get_elements: 獲取屏幕上的可交互元素列表
  • find_element: 根據描述查找特定元素

操作工具

  • click_element: 點擊指定元素
  • type_text: 輸入文字
  • drag_element: 拖拽元素
  • scroll: 滾動頁面

視窗管理工具

  • list_windows: 列出所有可用視窗
  • focus_window: 聚焦到指定視窗
  • capture_window: 截取指定視窗

開發

項目結構

omniparser-mcp/
├── src/
│   └── omniparser_mcp/
│       ├── __init__.py
│       ├── server.py          # MCP服務器主入口
│       ├── omniparser_client.py  # OmniParser模型客戶端
│       ├── automation/        # 自動化操作模組
│       ├── window_manager/    # 視窗管理模組
│       └── tools/            # MCP工具定義
├── tests/
├── config.json
├── pyproject.toml
└── README.md

運行測試

pytest tests/

📖 文檔

🤝 貢獻

我們歡迎所有形式的貢獻!

如何貢獻

  1. Fork 這個倉庫
  2. 創建您的功能分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 開啟一個 Pull Request

開發設置

# 克隆您的 fork
git clone https://github.com/yourusername/omniparser-mcp-server.git
cd omniparser-mcp-server

# 安裝開發依賴
pip install -e ".[dev]"

# 運行測試
pytest tests/ -v

# 代碼格式化
black src/ tests/
isort src/ tests/

🐛 問題報告

如果您發現了bug或有功能請求,請:

  1. 檢查 Issues 確認問題尚未被報告
  2. 創建新的 Issue 並提供詳細信息:
    • 操作系統和Python版本
    • 錯誤信息和堆棧跟踪
    • 重現步驟
    • 預期行為

📄 許可證

本項目採用 MIT 許可證 - 查看 LICENSE 文件了解詳情。

🙏 致謝

⭐ Star History

如果這個項目對您有幫助,請給我們一個 ⭐!

Star History Chart

Metadata

Release files for mcp-server-omniparser 0.1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-omniparser 0.1.0.3
File Size Uploaded
mcp_server_omniparser-0.1.0.3.tar.gz 39.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-omniparser 0.1.0.3
File Interpreter ABI Platform
mcp_server_omniparser-0.1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 81.4 kB

Release files / mcp_server_omniparser-0.1.0.3.tar.gz

Download URL mcp_server_omniparser-0.1.0.3.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b1272513e1d74f6c9ead5dbacc9c4aaff99a9c7c01424fcaa9132411ffba6441
BLAKE2b-256 checksum
How to use checksums
b089dd2cec34dd54741f20a0277cfcd10895696fe93e5a3197307c402f946462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release files / mcp_server_omniparser-0.1.0.3-py3-none-any.whl

Download URL mcp_server_omniparser-0.1.0.3-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16a062346d66d96a7f286fcf6c23d61c9e006204cdde728da5b0c1f1db950acf
BLAKE2b-256 checksum
How to use checksums
eeb52bed94d4ee7a973aa40240567b248fbea787ff867a9e364e1a5dce8749d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.0.3 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page