Using rn-dev-agent with React Native DevTools
You open React Native DevTools and it immediately disconnects with “Disconnected due to opening a second DevTools window”. Or your Metro logs are full of __RN_NET__:request:{...} lines. Both come from the rn-dev-agent CDP bridge — and both are fixed. This page explains what’s happening and how to configure it.
Why DevTools gets kicked
Section titled “Why DevTools gets kicked”React Native allows exactly one debugger frontend per app (on RN versions before dev-middleware learned to multiplex frontends). The rn-dev-agent bridge and the visual React Native DevTools window connect to the same /inspector/debug slot, so they evict each other — whoever connects last wins.
By default the bridge is agent-first: after any disconnect it auto-reconnects in the background (instant first retry, then a 5-second poll). So the moment you open DevTools, the bridge re-grabs the seat and your DevTools window gets kicked. You never had a chance.
The fix: turn off background auto-reconnect
Section titled “The fix: turn off background auto-reconnect”Two equivalent opt-out surfaces — the environment variable wins if both are set:
Environment variable (set where the MCP server starts, e.g. in your shell profile or the Claude Code MCP env):
RN_CDP_AUTOCONNECT=0 # also accepts 'false'; '1'/'true' force the default back onProject config file — .rn-agent/config.json in your React Native project root:
{ "cdp": { "autoConnect": false } }With either set, the bridge runs in passive mode: after a disconnect it stays down instead of re-grabbing the seat. Open React Native DevTools and it keeps the connection — Console, Network, Components, Profiler all work.
What passive mode does and doesn’t change
Section titled “What passive mode does and doesn’t change”- Disabled: all background reconnection — the close-triggered reconnect loop and the 5-second background poll. The bridge never takes the seat behind your back.
- Unchanged: on-demand connection. When the agent actually runs a CDP tool (
cdp_status,cdp_component_tree, …), the bridge connects for that work — which does evict your DevTools window at that moment. That’s deliberate: a tool call is a visible, foreground action. Once you reopen DevTools afterwards, the bridge yields again. - Unchanged:
device_*tools (taps, screenshots, fills). They don’t touch the debugger connection at all — use them freely while DevTools is open.
You can always see the resolved mode in cdp_status → top-level autoConnect field ({ enabled, source: 'env' | 'config' | 'default' }), and /rn-dev-agent:doctor reports it as the CDP auto-reconnect row (YELLOW when off — informational, not an error).
Known limitation: a DevTools-sharing proxy started with cdp_open_devtools is not auto-resumed after a disconnect in passive mode — re-run cdp_open_devtools if you use that flow.
The __RN_NET__ console spam is gone
Section titled “The __RN_NET__ console spam is gone”Unrelated knob, same release: on React Native < 0.83 the bridge falls back to in-app fetch/XHR wrappers for network capture, and these used to transport every request/response as a console.log('__RN_NET__:…') line — invisible to the bridge (it filters them) but spamming Metro logs and your DevTools console.
That transport is replaced: entries now go to an in-app ring buffer (globalThis.__RN_AGENT_NET_BUF__, capped at 100) that the network tools drain on demand. No configuration needed — update the plugin and the console noise disappears while cdp_network_log keeps working.
Quick reference
Section titled “Quick reference”| I want… | Do this |
|---|---|
| DevTools to stay connected while the agent is idle | RN_CDP_AUTOCONNECT=0 or .rn-agent/config.json → { "cdp": { "autoConnect": false } } |
| The agent-first default back | Remove the override, or RN_CDP_AUTOCONNECT=1 |
| To check which mode is active | cdp_status → autoConnect, or /rn-dev-agent:doctor |
No __RN_NET__ lines in my console | Nothing — fixed automatically as of this release |