面向 AI 智能体的 MCP

Lagsmith 内置 MCP 服务器。支持 MCP 的 AI 编程智能体(包括 Claude Code、Cursor、Codex、Claude Desktop 和 Windsurf)可以用它来:

  • 列出模拟器和 App;
  • 设置和重置 App 的网络;
  • 在启用请求监控的情况下重新启动 App;
  • 读取它的请求;
  • 让端点失败或模拟端点。

由于 Lagsmith 只为被测 App 限速,智能体自己的连接保持全速。

MCP 服务器随 App 一起提供,位于 /Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp,所以 Lagsmith 需要放在“应用程序”文件夹中。自动化(包括 MCP)属于 Pro 功能,14 天试用中已包含。

Claude Code

在终端中运行一次:

claude mcp add --scope user lagsmith -- "/Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp"

--scope user 让 Lagsmith 在所有项目中可用。开始一个新的 Claude Code 会话并运行 /mcp,检查它是否已连接。

Cursor

将以下内容添加到 ~/.cursor/mcp.json(或项目中的 .cursor/mcp.json):

~/.cursor/mcp.json
{
  "mcpServers": {
    "lagsmith": {
      "command": "/Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp"
    }
  }
}

Codex

将以下内容添加到 ~/.codex/config.toml:

~/.codex/config.toml
[mcp_servers.lagsmith]
command = "/Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp"

Claude Desktop

在 Claude Desktop 中,打开 Settings › Developer › Edit Config,然后添加:

~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "lagsmith": {
      "command": "/Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp"
    }
  }
}

然后重新启动 Claude Desktop。

Windsurf

将以下内容添加到 Windsurf 的 MCP 配置中:

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "lagsmith": {
      "command": "/Applications/Lagsmith.app/Contents/MacOS/lagsmith-mcp"
    }
  }
}

如果你的配置文件中已有其他服务器,请将 lagsmith 条目添加到现有的 mcpServers 部分中,而不是替换整个文件。

工具

Lagsmith 的 MCP 服务器为智能体提供 10 个工具:

工具作用主要参数
list_targets正在运行的模拟器及其 App、正在运行的 Mac App、预设和当前规则无
status所有规则、它们正在做什么,以及代理是否在运行无
set_network为单个 App 的网络限速或制造故障app、simulator;preset,或 down/up(kbps)、latency/jitter(ms)、loss(%);failure(airplane、refuse、timeout、drop、outages);hosts、hosts_mode
reset_network恢复全速;App 仍处于监视状态app、simulator
stop_watching完全关闭该 App 的规则app、simulator
relaunch_app在启用请求监控的情况下重新启动模拟器 Appapp、simulator
get_requestsApp 最近的 HTTP 请求,最新的在前app、simulator、limit、filter(例如 is:failed、status:5xx)、include_bodies
fail_endpoint让一个端点失败,其余部分照常工作app、simulator、pattern、kind(offline、timeout、status、delay)、value
mock_endpoint用虚构的响应应答一个端点app、simulator、pattern、status、body、content_type、delay
clear_endpoints移除端点故障和模拟app、simulator、pattern

会话示例

> 在 3G 下运行结账 UI 测试,让支付 API 返回 503,告诉我哪里出了问题。
我先在模拟器中找到这个 App。
lagsmith - list_targets (MCP)
simulators: iPhone 17 Pro (booted)apps: com.pantryhq.Pantry, com.apple.mobilesafari, …presets: Edge, 3G, DSL, LTE, WiFi, Very Bad Network, 100% Loss
lagsmith - set_network (MCP)(app: "com.pantryhq.Pantry", simulator: "booted", preset: "3G")
{"ok": true, "rule": "Pantry", "preset": "3G", "conditions": {"down": 780, "up": 330, "latency": 200}}
lagsmith - fail_endpoint (MCP)(app: "com.pantryhq.Pantry", simulator: "booted", pattern: "api.pantryhq.app/v1/payments", kind: "status", value: 503)
{"ok": true, "endpoints": [{"pattern": "api.pantryhq.app/v1/payments", "kind": "status", "value": 503}]}
lagsmith - relaunch_app (MCP)(app: "com.pantryhq.Pantry", simulator: "booted")
{"ok": true, "relaunched": ["Pantry on iPhone 17 Pro"]}
Bash(xcodebuild test -scheme PantryUITests -only-testing:PantryUITests/CheckoutTests -destination 'platform=iOS Simulator,name=iPhone 17 Pro')
Test Suite 'CheckoutTests' started✓ testCartLoads (4.8 s)✓ testApplyCoupon (6.1 s)✗ testPlaceOrder (30.0 s): Failed to find "Order confirmed" within 30 sExecuted 3 tests, with 1 failure
lagsmith - get_requests (MCP)(app: "com.pantryhq.Pantry", simulator: "booted", filter: "host:api.pantryhq.app is:failed", include_bodies: true)
POST https://api.pantryhq.app/v1/payments 503 injected by Lagsmith 2 msPOST https://api.pantryhq.app/v1/payments 503 injected by Lagsmith 1 msPOST https://api.pantryhq.app/v1/payments 503 injected by Lagsmith 1 ms(3 requests, 0.4 s apart)
lagsmith - reset_network (MCP)(app: "com.pantryhq.Pantry", simulator: "booted")
{"ok": true, "preset": "No Throttling"}
找到了。在 3G 下,购物车和优惠券流程都正常,但当支付接口返回 503 时: 1. PaymentService 没有退避地重试 3 次(间隔 0.4 秒),然后静默放弃。 2. 结账界面的加载指示器会一直转下去:支付失败时没有错误状态, 所以 testPlaceOrder 在等待“Order confirmed”时超时。 要我在 CheckoutView 中加入指数退避和带“重试”按钮的错误状态, 然后在相同条件下重新运行测试吗?
使用 Lagsmith MCP 服务器的 Claude Code 会话示意。你的智能体保持全速,只有 Pantry 处于 3G。

提示词示例

  • “在 3G 下启用监控并重新启动 App,登录,然后列出耗时超过两秒的请求。”
  • “让 App 进入飞行模式,检查离线横幅是否出现。”
  • “让 POST /v1/orders 返回 500,检查 App 是否显示重试按钮。”
下载 Mac 版

免费下载,含 14 天 Pro 试用。无需账户,无需银行卡。macOS 13 Ventura 或更高版本。