查找mcp ios
用于iOS UI检查的MCP服务器——允许任何AI代理(Claude Code、Cursor、Codex等)通过LookinServer检查实时iOS应用程序UI层次结构、属性和屏幕截图,无需Lookin.app。
______________________________________________________________________
先决条件
- iOS应用程序与 查找服务器MCP,在模拟器或设备上运行
- Node.js 18+
iOS集成
将以下内容添加到您的 Podfile:
pod 'LookinServerMCP', :configurations => ['Debug']仅包含在调试版本中——可以安全地永久保留在您的播客文件中。
______________________________________________________________________
运作原理
设备支持
MCP服务器支持iOS模拟器和物理设备:
iOS模拟器:
AI Agent (Claude Code / Cursor / Codex / ...)
↓ stdio (MCP protocol)
lookin-mcp-ios (Node.js)
↓ HTTP local port
LookinServer (embedded in iOS App)物理设备:
AI Agent (Claude Code / Cursor / Codex / ...)
↓ stdio (MCP protocol)
lookin-mcp-ios (Node.js)
↓ native usbmuxd socket (/var/run/usbmuxd)
↓ TCP proxy on :47191
LookinServer (embedded in iOS App)设备选择
- 单一设备:应用程序启动时自动连接
- 多个设备:提示用户通过以下方式选择设备
lookin_connect_device工具 - 设备事件:拔下物理设备时自动重新连接(退回模拟器)
______________________________________________________________________
安装
克劳德代码
claude mcp add --scope user lookin -- npx -y lookin-mcp-ios光标
添加 ~/.cursor/mcp.json (全球)或 .cursor/mcp.json 在项目根目录中:
{
"mcpServers": {
"lookin": {
"command": "npx",
"args": ["-y", "lookin-mcp-ios"]
}
}
}法典
添加 ~/.codex/config.yaml:
mcp_servers:
- name: lookin
command: npx
args:
- -y
- lookin-mcp-ios______________________________________________________________________
工具
lookin_list_devices
列出所有可连接的iOS目标:USB物理设备和启动的模拟器。
参数: 无
答复: JSON对象包含:
activeTarget--当前连接的目标(类型:"simulator"或"physical")devices--可用设备阵列,每个设备具有:
- udid --唯一设备标识符 - name --设备名称(例如“iPhone 15 Pro”) - type --设备类型("simulator" 或 "physical")
hint--使用说明
示例响应:
{
"activeTarget": { "type": "simulator" },
"devices": [
{ "udid": "ABC123...", "name": "iPhone 16 Pro", "type": "simulator" },
{ "udid": "XYZ789...", "name": "John's iPhone", "type": "physical" }
],
"hint": "Found 2 device(s). Use lookin_connect_device with a udid to connect."
}______________________________________________________________________
lookin_connect_device
将连接目标切换到物理设备或模拟器。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
target | string | 是 | 设备UDID(来自 lookin_list_devices)或 "simulator" 使用默认模拟器 |
答复: 确认消息和连接状态
______________________________________________________________________
lookin_get_hierarchy
返回正在运行的iOS应用程序的完整UI视图层次结构树。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
includeSystemViews | boolean | 否 | 保留参数,直接连接到LookinServer时没有过滤效果 |
maxDepth | number | 否 | 最大层次深度。如果省略,则返回所有级别 |
示例响应:
{"appName":"Demo","totalViews":12,"hierarchy":[{"oid":4393842688,"className":"UIWindow","frame":[0,0,390,844],"children":[{"oid":4393842944,"className":"MyViewController","frame":[0,0,390,844],"children":[]}]}]}节点字段:
oid--唯一视图标识符,用作其他工具的输入className--类名frame--位置和大小[x, y, width, height]hidden--仅在以下情况下出现truealpha--仅在非1.0时存在
______________________________________________________________________
lookin_get_attributes
返回指定视图的所有UI属性。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
oid | number | Yes | 视图ID(来自 lookin_get_hierarchy) |
答复: 按组分组的属性→ 部分→ 属性,每个属性包含:
identifier--属性标识符setterSelector--setter方法名称,例如。setBackgroundColor:attrType--值类型枚举value--当前值
attrType值:
| 值 | 类型 |
|---|---|
| 14 | 打球 |
| 12 | 浮动 |
| 13 | 双倍 |
| 5 | 更密集 |
| 20 | 正确 |
| 17 | CGPoint |
| 19 | CGSize |
| 22 | UIEdgeInsets |
| 23 | UIColor(RGBA数组,0~1) |
| 25 | 枚举整数 |
| 26 | 枚举长度 |
| 24 | NSString |
______________________________________________________________________
lookin_get_screenshot
从实时iOS应用程序渲染中捕获指定视图的屏幕截图。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
oid | number | No | View ID。如果省略,将自动使用根窗口进行全屏截图 |
答复: PNG格式的MCP图像内容,可由AI代理直接查看。
______________________________________________________________________
典型工作流程
1. lookin_list_devices → list available iOS targets (simulators and physical devices)
2. lookin_connect_device(target) → select the target device (if multiple devices available)
3. lookin_get_hierarchy → get the view tree and find the target view's oid
4. lookin_get_attributes(oid) → inspect all attributes of that view
5. lookin_get_screenshot(oid) → capture a screenshot to see the current UI state如果只有一个设备可用,则步骤1-2在启动时自动处理。
