Simulator MCP
Simulator MCP
Ermöglicht es der KI, iOS-Simulatoren über das MCP-Protokoll zu steuern – Geräte starten, Screenshots erstellen, tippen, Text eingeben, Netzwerkverkehr abfangen und Schnittstellen mocken.
Funktionsübersicht
Kategorie | Werkzeug | Beschreibung |
Geräteverwaltung |
| Listet alle Simulatoren auf (Status, UDID, Runtime) |
| Startet / Stoppt den Simulator | |
| Installiert ein .app-Paket | |
| Startet eine APP (unterstützt | |
| Öffnet eine URL oder einen Deep Link (wählt automatisch den gestarteten Simulator aus) | |
Screenshots |
| Erstellt einen Screenshot und sendet ihn als Base64-Bild an die KI (unterstützt visuelle Analyse) |
UI-Interaktion |
| Tippt auf bestimmte iOS-Koordinaten (unterstützt langes Drücken via |
| Wischt vom Start- zum Endpunkt | |
| Gibt Text in das aktuell fokussierte Eingabefeld ein | |
| Drückt Hardware-Tasten ( | |
| Ruft den UI-Accessibility-Baum ab (JSON-Format) | |
| Sucht Elemente anhand von Text und tippt auf deren Mittelpunkt | |
Netzwerk-Interzeption |
| Startet den mitmproxy (Standard-Port 8080) |
| Stoppt den Proxy | |
| Zeigt aufgezeichnete Netzwerkprotokolle an (unterstützt Filterung nach URL, Methode) | |
| Fügt eine Mock-Regel hinzu (URL-Regex-Matching) | |
| Entfernt eine Mock-Regel |
Insgesamt 18 Werkzeuge, die die drei Bereiche Geräteverwaltung, UI-Automatisierung und Netzwerk-Interzeption abdecken.
Related MCP server: Shotter
Voraussetzungen
Abhängigkeit | Zweck | Installationsmethode |
Xcode | Stellt den Befehl | Mac App Store |
idb-companion | Native Daemon für fb-idb (UI-Automatisierung) |
|
Python >= 3.11 | Laufzeitumgebung |
|
uv (empfohlen) | Paketverwaltung |
|
Das im Repository enthaltene
proxy-dylib/libproxy_inject.dylibist einarm64-Prebuild; für Intel-Macs muss es selbst fürx86_64oder als Universal-Binary neu kompiliert werden.
Installation
cd simulator-mcp
# 方式一:uv(推荐)
uv venv && uv pip install -e .
# 方式二:pip
python -m venv .venv && source .venv/bin/activate && pip install -e .Python-Abhängigkeiten (automatische Installation):
mcp >= 1.0— MCP-Protokoll-SDK (stdio JSON-RPC)mitmproxy >= 10.0— HTTP(S)-Proxyfb-idb— iOS-Simulator-UI-Automatisierung
Konfiguration für Claude Code
Fügen Sie dies in ~/.claude.json unter mcpServers hinzu:
{
"mcpServers": {
"simulator": {
"command": "/path/to/simulator-mcp/.venv/bin/simulator-mcp"
}
}
}Konfiguration für Claude Desktop
Fügen Sie dies in ~/Library/Application Support/Claude/claude_desktop_config.json hinzu:
{
"mcpServers": {
"simulator": {
"command": "/path/to/simulator-mcp/.venv/bin/simulator-mcp"
}
}
}Ersetzen Sie
/path/to/simulator-mcpdurch den absoluten Pfad zum Projekt.
Anwendungsbeispiel
Nach der Konfiguration kann die KI den Simulator direkt steuern:
用户: 打开模拟器,截图看看当前页面
AI: 调用 list_devices → boot_device → take_screenshot
"当前页面显示的是 iOS 主屏幕..."
用户: 打开微博,点击注册按钮
AI: 调用 launch_app → take_screenshot → tap_element(text="注册")
"已点击注册按钮,进入了注册页面"
用户: 抓包看看注册接口返回了什么
AI: 调用 start_network_proxy → launch_app(proxy=true) → get_network_log(url_pattern="register")
"注册接口返回了 200,响应体是..."
用户: Mock 掉登录接口,返回自定义数据
AI: 调用 add_mock_rule(url_pattern="api/login", response_body='{"token":"fake"}')
"已添加 Mock 规则 mock_1"Hinweise zum Netzwerk-Sniffing
Ablauf
Proxy starten:
start_network_proxy(port=8080)Startet mitmproxy automatisch in einem Hintergrund-Thread
Falls bereits ein Simulator gestartet ist, wird versucht, das mitmproxy-CA-Zertifikat zu installieren
APP mit Proxy starten:
launch_app(udid="xxx", bundle_id="com.example.app", proxy=true)Injiziert
libproxy_inject.dylibviaDYLD_INSERT_LIBRARIESSwizzelt
NSURLSessionConfiguration, um den gesamten HTTP(S)-Verkehr an den Proxy weiterzuleitenInstalliert das CA-Zertifikat erneut auf dem Ziel-Simulator, um HTTPS-Fehler zu vermeiden, falls der Proxy nach dem Simulator gestartet wurde
Anfragen anzeigen/mocken:
get_network_log(url_pattern="api/user")— Filterung nach URL-Teilstringadd_mock_rule(url_pattern="api/login", response_body="...")— URL-Regex-Matching
Technische Grundlagen
App 启动 → dylib 注入 → swizzle NSURLSessionConfiguration
→ 所有 NSURLSession 流量 → mitmproxy (127.0.0.1:8080)
→ MockEngine 检查规则 → 命中则返回假数据 / 未命中则转发真实服务器
→ NetworkLog 记录请求/响应(内存环形缓冲,最多 1000 条)
→ 同时落盘:
- `/tmp/proxy_requests.log`:摘要日志
- `/tmp/proxy_requests.jsonl`:结构化明细日志
- `/tmp/proxy_request_bodies/`:超大 body 的分流文件Projektstruktur
simulator-mcp/
├── pyproject.toml # 项目配置、依赖、入口定义
├── README.md # 本文件
├── ARCHITECTURE.md # 技术架构详细文档
├── diagrams/ # Mermaid 源文件 + PNG 架构图
├── proxy-dylib/
│ ├── proxy_inject.m # DYLD 注入源码 (Objective-C, 95 行)
│ └── libproxy_inject.dylib # 编译产物 (当前为 arm64)
└── src/simulator_mcp/
├── __init__.py # 入口: main() → asyncio.run(server.main())
├── __main__.py # python -m simulator_mcp 入口
├── server.py # MCP Server: 18 个工具注册 + call_tool 分发
├── simulator/
│ ├── simctl.py # xcrun simctl 异步封装 (设备管理 + 截图)
│ └── idb_client.py # fb-idb 异步封装 (UI 交互 + tap_element)
├── tools/
│ ├── device.py # 设备管理工具 (参数解析 + proxy 注入逻辑)
│ ├── screenshot.py # 截图工具 (PNG → base64)
│ ├── ui.py # UI 交互工具 (参数解析 → idb_client)
│ └── network.py # 网络工具 (参数解析 → proxy_server)
└── proxy/
├── proxy_server.py # mitmproxy 生命周期 + ProxyAddon + CA 证书安装
├── network_log.py # 请求日志: 内存环形缓冲 + 结构化落盘
└── mock_engine.py # Mock 规则引擎: 正则匹配, 首条命中Dylib neu kompilieren (optional)
Falls proxy_inject.m geändert wurde:
cd proxy-dylib
clang -dynamiclib -framework Foundation \
-arch arm64 -arch x86_64 \
-o libproxy_inject.dylib \
proxy_inject.mArchitektur-Dokumentation
Das detaillierte technische Architekturdesign finden Sie unter ARCHITECTURE.md.
This server cannot be deployed
Maintenance
Related MCP Connectors
Build, run, and inspect iOS apps in disposable hosted Simulators from cloud coding agents.
Control real Android and iOS devices with LLM agents — tap, swipe, type, automate flows.
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
Cloud macOS with Xcode for AI agents: run commands, build, test and ship iOS apps.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables interaction with iOS simulators by providing tools to inspect UI elements, control UI interactions, and manage simulators through natural language commands.177,301 npm2,193MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to automate iOS Simulator interactions including device management, UI element interaction (tap, swipe, type), screenshot capture, and execution of YAML-defined navigation workflows.10 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive control of iOS simulators and real devices through AI assistants, supporting app management, UI automation, screenshots, media operations, and location simulation for iOS development and testing workflows.8MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides comprehensive tools for managing iOS simulators, including device control, app lifecycle management, and UI automation. It enables developers to boot devices, install apps, capture screenshots, and simulate user interactions through natural language commands.4MIT