Skip to content

Getting Started

metro-mcp is a plugin-based MCP server for React Native runtime debugging, inspection, and automation. It 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.

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.

Installation

Claude Code

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

Codex

bash
codex mcp add metro-mcp -- npx -y metro-mcp
# or with Bun
codex 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 want to add the server manually, use:

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 use the one-click install buttons:

Install in VS CodeInstall in Cursor

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

With a config file

In Claude Code, Cursor, VS Code, and OpenCode, metro-mcp automatically discovers metro-mcp.config.ts (or .js) from your project root — no extra configuration needed. Just add the file and it will be picked up.

bash
# Install metro-mcp as usual
claude mcp add metro-mcp -- bunx metro-mcp

If your client doesn't support MCP roots, pass the config path explicitly:

bash
claude mcp add metro-mcp -- bunx metro-mcp --config /Users/you/my-project/metro-mcp.config.ts

See Configuration for all options.

With a custom Metro port

bash
claude mcp add metro-mcp -- npx -y metro-mcp --port 19000
codex 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"]

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.

Compatibility

Supported
React Native0.70+ (Hermes required)
ExpoSDK 49+
Node.js18+
Bun1.0+
PlatformsiOS Simulator, Android Emulator, physical devices via USB

Chrome DevTools

Hermes only allows a single CDP connection at a time. metro-mcp solves this with a built-in CDP proxy that multiplexes the connection, letting Chrome DevTools and the MCP coexist.

Use the open_devtools MCP tool instead of pressing "j" in Metro or tapping "Open Debugger" in the dev menu — those will steal the connection and disconnect the MCP.

The proxy is enabled by default. To configure it:

bash
# Fixed proxy port
METRO_MCP_PROXY_PORT=9222 npx metro-mcp

# Disable the proxy
METRO_MCP_PROXY_ENABLED=false npx metro-mcp

Claude Code Status Bar

Get live Metro 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:

/statusline add the script at ~/.claude/metro-mcp-statusline.sh
StateDisplay
Not runningMetro ○ (dimmed)
Running, not connectedMetro ● (red)
ConnectedMetro ● localhost:8081 (green)

Next Steps

Released under the MIT License.