性能分析工具

InstrumentsMCP是一个基于Xcode Instruments的MCP服务器,用于记录跟踪、自动化模拟器并返回结构化分析数据,供编码代理使用。

  • by nemanjavlahovic
  • TypeScript
  • 本地部署
  • 19 星标
  • 更新于
在 GitHub 查看 nemanjavlahovic/instruments-mcp-server

使用说明

InstrumentsMCP

Profiler data for agents.

封装Xcode Instruments的MCP服务器。记录跟踪,自动化模拟器,并返回编码代理可以处理的结构化分析数据。

快速开始

要求: macOS、Xcode、Node.js>=20

添加到您的项目 .mcp.json:

{
  "mcpServers": {
    "instruments": {
      "command": "npx",
      "args": ["-y", "instrumentsmcp@latest"]
    }
  }
}

或者直接运行: npx instrumentsmcp@latest

适用于Claude Code、Cursor、Windsurf和任何MCP客户端。

它做什么

让你的经纪人介绍一下。它记录跟踪,驱动模拟器,并返回结构化结果:

=== Time Profiler ===  severity: [WARNING]  samples: 1587

Hotspots:
  UpdateStack::update() (AttributeGraph)  42.3ms self ━━━━━━╌╌╌╌╌╌╌╌╌ 12.1%
  FeedViewModel.loadItems() (MyApp)        28.1ms self ━━━━╌╌╌╌╌╌╌╌╌╌╌ 8.0%

Main thread blockers:
  [WARNING] FeedViewModel.loadItems()  28.1ms

35个工具,涵盖分析、UI自动化、模拟器控制和跟踪分析。 完整工具列表→

分析

  • 一次性 — profile_cpu, profile_swiftui, profile_memory, profile_hitches, profile_launch, profile_energy, profile_leaks, profile_network
  • 脚本化场景 — profile_scenario 在执行UI步骤(点击、滚动、键入、启动)时记录跟踪
  • 交互式 — start_profiling / stop_profiling 用于手动交互
  • 健康检查 — performance_audit 运行5个模板并组合结果
  • 任何模板 — profile_raw 在没有专用解析器的情况下处理模板

UI自动化

以编程方式驱动模拟器: ui_tap, ui_type, ui_swipe, ui_gesture, ui_snapshot, ui_long_press.技术支持: AXe CLI (brew tap cameroncooke/axe && brew install axe).

模拟器控制

启动/终止应用程序、打开深度链接、推送通知、截图、设置位置、切换黑暗模式。

分析

重新分析保存的痕迹,深入特定功能,跟踪基线回归,生成Markdown报告。

命令行接口命令模式

在没有MCP客户端的情况下记录终端的痕迹:

npx instrumentsmcp record --process MyApp
npx instrumentsmcp record --process MyApp --template Allocations

按Ctrl+C停止。将痕迹提供给您的代理人进行分析。

兼容性

  • Xcode Instruments(xctrace)15.x到26.x
  • 自动处理xctrace 26延迟录制模式
  • 设备标识符(booted、设备名称、UDID)自动解析

文档

Architecture
src/
├── index.ts              # MCP server entry + CLI router
├── cli.ts                # CLI mode (instrumentsmcp record)
├── tools/
│   ├── profile.ts        # One-shot profiling tools
│   ├── simulator.ts      # Simulator control + start/stop + scenarios
│   ├── analyze.ts        # Trace analysis + symbolication + audit
│   ├── baseline.ts       # Baseline comparison + report generation
│   ├── investigate.ts    # Drill-down + trace listing
│   ├── ui.ts             # UI automation (snapshot, tap, type, swipe)
│   └── list.ts           # Discovery tools (status, templates, devices)
├── parsers/              # Template-specific XML→JSON parsers
└── utils/                # xctrace, simctl, AXe wrappers + shared helpers
Build from source
git clone https://github.com/nemanjavlahovic/instruments-mcp-server.git
cd instruments-mcp-server
npm install && npm run build

将您的MCP客户端指向 dist/index.js.

许可证

麻省理工学院