iOS模拟器控制协议服务器

一个MCP(模型上下文协议)服务器,为Claude Code提供对iOS模拟器的代理控制,用于UI/UX调试和开发。

  • by AKAICH00
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 AKAICH00/ios-simulator-mcp-server

使用说明

iOS模拟器MCP服务器

MCP(模型上下文协议)服务器,为Claude Code提供对iOS模拟器的代理控制,用于UI/UX调试和开发。

特性

模拟器控制

  • 列出、启动和关闭模拟器
  • 截图
  • 设置位置,状态栏覆盖
  • 提醒推送
  • 管理应用程序权限

应用管理

  • 安装、启动和终止应用程序
  • 列出已安装的应用程序
  • 打开网址
  • 访问应用程序容器

UI交互(需要IDB)

  • 点击坐标
  • 滑动手势
  • 文本输入
  • 硬件按钮按下

深度UI调试(需要ClaudeDebugKit)

  • 完成视图层次结构检查
  • 自动布局约束分析
  • 触摸目标尺寸审核(最小44pt)
  • 颜色对比度审计(WCAG AA/AAA)
  • 可访问性审计
  • 字体和颜色检查
  • 视图突出显示
  • 特性收集覆盖(暗模式、动态类型)
  • 内存统计数据和性能指标

安装

先决条件

  1. Xcode iOS模拟器
  2. Node.js 18+
  3. 国际开发银行 (可选,用于UI交互):
    brew install idb-companion
    pip install fb-idb
    

安装MCP服务器

cd ios-simulator-mcp-server
npm install
npm run build

配置Claude代码

添加到您的Claude Code MCP配置中(~/.config/claude-code/mcp.json):

{
  "mcpServers": {
    "ios-simulator": {
      "command": "node",
      "args": ["/path/to/ios-simulator-mcp-server/dist/index.js"]
    }
  }
}

将ClaudeDebugKit添加到您的iOS应用程序

对于深度UI检查功能,请将Swift包添加到您的iOS项目中:

  1. 在Xcode中:文件→ 添加包依赖关系
  2. 输入: file:///path/to/ClaudeDebugKit
  3. 添加到您的应用程序(仅限调试版本):
#if DEBUG
import ClaudeDebugKit

// In AppDelegate or SceneDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions...) {
    ClaudeDebugServer.shared.start()
    return true
}
#endif

使用示例

基本模拟器控制

"List all available iOS simulators"
"Boot iPhone 15 Pro"
"Take a screenshot of the simulator"
"Set the location to San Francisco (37.7749, -122.4194)"

应用程序开发工作流

"Install my app from ~/Build/MyApp.app and launch it"
"Get the view hierarchy of the current screen"
"Find all interactive elements"
"Audit touch targets for HIG compliance"

UI/UX调试

"Check color contrast for WCAG AA compliance"
"Show me the constraints on the login button"
"Highlight the view with accessibility label 'Submit'"
"Run a full UI/UX audit"

测试不同的配置

"Switch to dark mode"
"Override Dynamic Type to extra large"
"Simulate a memory warning"
"Get memory stats for the app"

可用工具

模拟器管理

工具 说明
ios_list_devices 列出所有模拟器
ios_boot_device 启动模拟器
ios_shutdown_device 关闭模拟器
ios_screenshot 截图
ios_set_location 设置GPS位置
ios_set_status_bar 覆盖状态栏
ios_push_notification 发送推送通知
ios_set_permission 授予/撤销权限
ios_get_logs 获取应用程序日志

应用管理

工具 说明
ios_install_app 安装.app捆绑包
ios_launch_app 启动应用程序
ios_terminate_app 终止应用程序
ios_list_apps 列出已安装的应用程序
ios_open_url 打开URL
ios_get_app_container 获取容器路径

UI交互(需要IDB)

工具 说明
ios_tap 点击坐标或标签
ios_swipe 滑动手势
ios_input_text 键入文本
ios_press_button 硬件按钮
ios_long_press 长按

查看调试(需要ClaudeDebugKit)

工具 说明
ios_get_view_hierarchy 全景树
ios_get_constraints 自动布局约束
ios_find_element 按标签/标识符查找
ios_get_view_colors 颜色信息
ios_get_font_info 字体详细信息
ios_highlight_view 视觉突出显示
ios_get_interactive_elements 所有可敲击元件
ios_get_responder_chain 应答器链
ios_get_traits 特征收集
ios_override_traits 覆盖外观
ios_get_memory_stats 内存使用情况
ios_export_view_image 将视图导出为PNG

审计(需要ClaudeDebugKit)

工具 说明
ios_audit_touch_targets 检查最小44pt
ios_audit_contrast WCAG对比度检查
ios_audit_layout 自动布局问题
ios_audit_accessibility 无障碍问题
ios_audit_all 完整的UI/UX审核

建筑

┌─────────────────────────────────────────────────────────┐
│                     Claude Code                          │
└─────────────────────┬───────────────────────────────────┘
                      │ MCP Protocol (stdio)
                      ▼
┌─────────────────────────────────────────────────────────┐
│              ios-simulator-mcp-server                    │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────┐ │
│  │   simctl    │  │     IDB     │  │  Debug Client   │ │
│  │  (built-in) │  │ (optional)  │  │   (HTTP)        │ │
│  └──────┬──────┘  └──────┬──────┘  └────────┬────────┘ │
└─────────┼────────────────┼──────────────────┼──────────┘
          │                │                  │
          ▼                ▼                  ▼
┌─────────────────────────────────────────────────────────┐
│                    iOS Simulator                         │
│  ┌───────────────────────────────────────────────────┐ │
│  │                   Your iOS App                     │ │
│  │  ┌─────────────────────────────────────────────┐  │ │
│  │  │            ClaudeDebugKit                    │  │ │
│  │  │         (HTTP Server on :8765)               │  │ │
│  │  └─────────────────────────────────────────────┘  │ │
│  └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘

需求

  • macOS与Xcode 15+
  • Node.js 18+
  • ClaudeDebugKit的iOS 14+目标

许可证

麻省理工学院