MCP Server for UI automation using Microsoft OmniParser model for screen parsing and element detection
Project description
OmniParser MCP Server
一個基於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/
📖 文檔
🤝 貢獻
我們歡迎所有形式的貢獻!
如何貢獻
- Fork 這個倉庫
- 創建您的功能分支 (
git checkout -b feature/AmazingFeature) - 提交您的更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 開啟一個 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或有功能請求,請:
- 檢查 Issues 確認問題尚未被報告
- 創建新的 Issue 並提供詳細信息:
- 操作系統和Python版本
- 錯誤信息和堆棧跟踪
- 重現步驟
- 預期行為
📄 許可證
本項目採用 MIT 許可證 - 查看 LICENSE 文件了解詳情。
🙏 致謝
- Microsoft OmniParser - 核心UI解析模型
- Model Context Protocol - MCP協議規範
- 所有貢獻者和用戶
⭐ Star History
如果這個項目對您有幫助,請給我們一個 ⭐!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_omniparser-0.1.0.3.tar.gz.
File metadata
- Download URL: mcp_server_omniparser-0.1.0.3.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1272513e1d74f6c9ead5dbacc9c4aaff99a9c7c01424fcaa9132411ffba6441
|
|
| MD5 |
63805e2a78dfd27608fe22674e46f887
|
|
| BLAKE2b-256 |
b089dd2cec34dd54741f20a0277cfcd10895696fe93e5a3197307c402f946462
|
File details
Details for the file mcp_server_omniparser-0.1.0.3-py3-none-any.whl.
File metadata
- Download URL: mcp_server_omniparser-0.1.0.3-py3-none-any.whl
- Upload date:
- Size: 42.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16a062346d66d96a7f286fcf6c23d61c9e006204cdde728da5b0c1f1db950acf
|
|
| MD5 |
c52b41372679be4bfe0a15dc95758cfb
|
|
| BLAKE2b-256 |
eeb52bed94d4ee7a973aa40240567b248fbea787ff867a9e364e1a5dce8749d1
|