Metro MCP

io.github.steve228uk由 GitHub 账号 steve228uk 发布v0.15.0更新于 Oct 24, 2026

MCP server for React Native/Expo runtime debugging, inspection, and automation via Metro/CDP

已验证STDIO仅桌面浏览器自动化开发者工具

概览

AI 生成的概览

一个本地 MCP 服务器,连接 React Native 或 Expo 应用的 Metro 打包服务,用于调试、检查并自动化正在运行的应用。

可以做什么
通过 Metro 与 Hermes 的 CDP 连接查看运行时日志、网络请求、错误、环境与构建标志,并对堆栈进行符号化,内置代理可与 Chrome DevTools 同时使用。在应用运行时执行 JavaScript,检查 Redux 状态、React 组件树、导航状态和 AsyncStorage 内容。控制设备与模拟器、管理应用权限、测试深度链接,并通过点击、滑动和输入实现 UI 自动化。录制交互并生成 Appium、Maestro 或 Detox 测试,进行 CPU 与堆分析以及无障碍审计。浏览并读取应用沙盒目录中的文件,并调用通过可选应用集成注册的自定义命令。
适用场景
适合在开发、调试或测试基于 Metro 与 Hermes 的 React Native 或 Expo 应用时使用,让助手读取日志、检查状态、操作界面或生成测试,而无需修改应用代码。
运行要求
通过 npx 或 bunx 在本地运行(Node.js 18+ 或 Bun 1.0+)。需要运行中的 Metro 开发服务器,应用为 React Native 0.70+ 或 Expo SDK 49+ 且使用 Hermes。iOS 需要 Xcode 14+ 及模拟器;Android 需要 Android SDK 且 adb 在 PATH 中;部分 iOS 操作可选需要 IDB。可选环境变量 METRO_MCP_PROXY_PORT 和 METRO_MCP_PROXY_ENABLED 用于配置 CDP 代理。
安装前请注意
它连接运行中的应用,可执行 JavaScript、派发 Redux action、更改权限、重载应用、自动化界面并读取应用沙盒文件(包括 SQLite 数据库),相当于对开发版应用拥有完全控制权。应用中注册的自定义命令可执行登录或清除已存数据等操作。在 Metro 中按 j 或选择 Open Debugger 会断开连接,除非使用代理。可选的状态栏设置会向用户主目录写入脚本。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Metro MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

metro-mcp

[Install in VS Code] [Install in Cursor]

A plugin-based MCP server for React Native runtime debugging, inspection, and automation. Connects to Metro bundler via Chrome DevTools Protocol — no app code changes needed for most features.

Works with Expo, bare React Native, and any project using Metro + Hermes.


Contents


Quick Start

Claude Code

bash
claude mcp add metro-mcp -- npx -y metro-mcp# or with Bunclaude mcp add metro-mcp -- bunx metro-mcp

Codex

bash
codex mcp add metro-mcp -- npx -y metro-mcp# or with Buncodex mcp add metro-mcp -- bunx metro-mcp

Codex stores MCP servers in ~/.codex/config.toml by default, and the Codex CLI and IDE extension share that configuration.

If you prefer to configure it manually:

toml
[mcp_servers.metro-mcp]command = "npx"args = ["-y", "metro-mcp"]

OpenCode

Run OpenCode's interactive MCP installer:

bash
opencode mcp add

Choose a local server, name it metro-mcp, and use npx -y metro-mcp as the command.

If you prefer to configure it manually, add this to opencode.json in your project, or to ~/.config/opencode/opencode.json for a global install:

json
{  "$schema": "https://opencode.ai/config.json",  "mcp": {    "metro-mcp": {      "type": "local",      "command": ["npx", "-y", "metro-mcp"],      "enabled": true    }  }}

Or with Bun:

json
{  "$schema": "https://opencode.ai/config.json",  "mcp": {    "metro-mcp": {      "type": "local",      "command": ["bunx", "metro-mcp"],      "enabled": true    }  }}

Cursor / VS Code

json
{  "mcpServers": {    "metro-mcp": {      "command": "npx",      "args": ["-y", "metro-mcp"]    }  }}

Or with Bun:

json
{  "mcpServers": {    "metro-mcp": {      "command": "bunx",      "args": ["metro-mcp"]    }  }}

Install across multiple agents

If you use several MCP clients, add-mcp can write the config for supported agents, including Claude Code, Codex, Cursor, OpenCode, and VS Code:

bash
npx add-mcp metro-mcp --all -g -y

metro-mcp supports multiple agents at the same time. Standard stdio installs start or reuse a local shared daemon for the same project directory and Metro/config options, so Codex, Claude Code, Cursor, and other clients can connect concurrently to the same running Metro app and see the same logs, network requests, errors, and runtime state.

Shared HTTP server / Supergateway

If you want to expose one long-lived MCP endpoint yourself, start the shared server explicitly:

bash
npx -y metro-mcp serve --mcp-port 8765

This serves Streamable HTTP at http://127.0.0.1:8765/mcp. The endpoint supports both the 2025-era MCP handshake and the 2026-07-28 negotiation; /sse and /messages are intentionally unavailable. Tools such as supergateway can point at the Streamable HTTP endpoint instead of launching a fresh stdio process per request.

With custom Metro port

bash
codex mcp add metro-mcp -- npx -y metro-mcp --port 19000# orclaude mcp add metro-mcp -- npx -y metro-mcp --port 19000

For OpenCode, add the port to the command array:

json
"command": ["npx", "-y", "metro-mcp", "--port", "19000"]

Requirements

  • Node.js 18+ or Bun 1.0+
  • iOS: Xcode 14+ with Simulator (xcrun simctl is used for most operations)
  • Android: Android SDK with adb on your PATH
  • IDB (optional): Some iOS operations fall back to IDB (idb-companion) — install with brew install idb-companion. Tools will tell you when IDB is needed.

How It Works

metro-mcp connects to your running Metro dev server the same way Chrome DevTools does:

  1. Discovers Metro via port scanning (8081, 8082, 19000–19002)
  2. Connects to Hermes via Chrome DevTools Protocol (CDP)
  3. Streams console logs, network requests, and errors into buffers
  4. Exposes everything as MCP tools, resources, and prompts

No app modifications required for core debugging features.


Features

PluginToolsDescription
console2Console log collection with filtering
network6Network request tracking, response body inspection, and stats
errors3Runtime exception collection + Metro bundle error detection
evaluate1Execute JavaScript in the app runtime
device4Device management, connection status, and app reload
environment4Build flags, platform constants, env vars, and Expo config inspection
source1Stack trace symbolication
redux3Redux state inspection and action dispatch
components5React component tree inspection
storage3AsyncStorage reading
simulator6iOS simulator / Android device control
deeplink2Cross-platform deep link testing
permissions5Inspect and manage app permissions on iOS Simulator and Android Emulator
ui-interact6UI automation (tap, swipe, type)
navigation4React Navigation / Expo Router state
accessibility3Accessibility auditing
commands2Custom app commands
automation3Wait/polling helpers for async state changes
profiler9CPU profiling (React DevTools hook) + heap sampling + render tracking
test-recorder7Record interactions and generate Appium, Maestro, or Detox tests
filesystem5Browse and read files in app sandbox directories (Documents, caches, SQLite DBs)
devtools1Open Chrome DevTools alongside the MCP via CDP proxy
debug-globals1Auto-discover Redux stores, Apollo Client, and other debug globals
inspect-point1Coordinate-based React component inspection (experimental)
statusline1Claude Code status bar integration

→ See the full tools reference.


Chrome DevTools

Hermes (the React Native JavaScript engine) only allows a single CDP debugger connection at a time. Since metro-mcp uses that connection, pressing "j" in Metro or tapping "Open Debugger" in the dev menu will steal the connection and disconnect the MCP.

metro-mcp solves this with a built-in CDP proxy that multiplexes the single Hermes connection, allowing Chrome DevTools and the MCP to work simultaneously.

Opening DevTools

Use the open_devtools MCP tool instead of the usual methods. It opens the same React Native DevTools frontend (rn_fusebox) that Metro uses, but routes the WebSocket connection through the proxy so both can coexist.

The tool automatically finds Chrome or Edge using the same detection as Metro and opens a standalone DevTools window.

What to avoid

MethodWhat happens
Pressing "j" in Metro terminalDisconnects the MCP
"Open Debugger" in the dev menuDisconnects the MCP
open_devtools MCP toolWorks alongside the MCP

Configuration

The CDP proxy is enabled by default. To change the port or disable it:

bash
# Set a fixed proxy portMETRO_MCP_PROXY_PORT=9222 npx metro-mcp
# Disable the proxy entirelyMETRO_MCP_PROXY_ENABLED=false npx metro-mcp

Claude Code Status Bar

Get live Metro CDP connection status in your Claude Code status bar.

Run setup_statusline in Claude Code — it writes a script to ~/.claude/metro-mcp-statusline.sh, then ask Claude to add it to your status bar:

/statusline add the script at ~/.claude/metro-mcp-statusline.sh

The status bar segment shows three states:

StateDisplay
Not runningMetro ○ (dimmed)
Running, not connectedMetro ● (red)
ConnectedMetro ● localhost:8081 (green)

Test Recording

Record real user interactions (taps, text entry, scrolls) and generate production-ready tests — no app code changes required.

AI-driven test generation

Describe a flow and the AI navigates the app, then generates the test:

"Write an Appium test for the guest checkout flow — start by tapping 'Start Shopping' on the welcome screen and end when the cart screen is visible."

The AI calls start_test_recording, navigates using tap_element/type_text/swipe, then generates a complete test with real selectors observed from the fiber tree.

Manual recording

start_test_recording   → inject interceptors(interact with the app)stop_test_recording    → retrieve event loggenerate_test_from_recording format=appium

Supports Appium (WebdriverIO), Maestro YAML, and Detox.

→ See the testing guide for full details, format examples, and tips.


App Integration (Optional)

Register custom commands and expose state to the MCP server — no package needed. Add this to your app entry point in dev mode:

typescript
if (__DEV__) {  globalThis.__METRO_BRIDGE__ = {    commands: {      // Run custom actions from the MCP client      login: async ({ email, password }) => {        return await authService.login(email, password);      },      resetOnboarding: () => {        AsyncStorage.removeItem('onboarding_completed');      },      switchUser: ({ userId }) => {        store.dispatch(switchUser(userId));      },    },    state: {      // Expose state snapshots readable via get_redux_state      userStore: () => useUserStore.getState(),    },  };}

Use list_commands and run_command to call these from the MCP client.

For enhanced features like real-time Redux action tracking, navigation events, performance marks, and React render profiling, install metro-bridge — see the client SDK docs and profiling guide.


Configuration

See configuration docs for environment variables, CLI arguments, and config file options.


Custom Plugins

metro-mcp is fully extensible. See the plugins guide to build your own tools and resources.


Compatibility

  • React Native: 0.70+ (Hermes required)
  • Expo: SDK 49+
  • Runtime: Node.js 18+ or Bun 1.0+
  • Platforms: iOS Simulator, Android Emulator, physical devices via USB

License

MIT

来源:README.md,提交 09b27c7

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.15.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分