Skip to main content
Glama
GinzaTech
by GinzaTech

RN Agent Observer

DE · English

RN Agent Observer 2.4.0 ist eine lokale Laufzeit-Beobachtungsbrücke für React Native/Expo. Das Tool verwendet denselben TypeScript-Kern für CLI und MCP, steuert Android über ADB/UIAutomator, empfängt Telemetrie von Entwicklungs-Instrumentierung, exportiert Console/Exception/Heap/JS-CPU-Profile über das Chrome DevTools Protocol von Metro, erfasst Netzwerkverkehr pro Anfrage ohne Instrumentierung, erstellt Screen-Understanding mit State/Headline/Actions/UI-Findings für Agenten, bietet sessionstabile Ref-Snapshots + Diff + automatisch aufgezeichnete Replays, nimmt Bildschirmvideos auf, speichert Sitzungen in SQLite und hält Bilder/Traces/UI-Bäume als Artefakte auf der Festplatte.

Die aktuelle Version schließt Android v1 unter Windows ab: 45 MCP-Tools, das passende CLI, eine Expo-Demo mit deterministischen Labs, transparente heuristische Diagnose und Bild- + UI-Strukturvergleich.

Anforderungen

  • Node.js 22.12 oder neuer

  • pnpm 9.6

  • Android Platform Tools (adb)

  • Android-Emulator oder physisches Gerät mit aktiviertem USB-Debugging

  • Expo-Development-Build, falls anwendungsspezifische Telemetrie benötigt wird

Related MCP server: React Native MCP Server

Schnellstart

pnpm install
pnpm check
adb devices -l
pnpm rn-observe --help
pnpm mcp:check

Richten Sie den Observer auf Ihre Expo/React-Native-App:

$env:RN_OBSERVER_PROJECT_ROOT = 'C:\path\to\expo-app'
$env:RN_OBSERVER_DEVICE_ID = 'emulator-5554'
# Có thể bỏ qua nếu app.json chứa expo.android.package
$env:RN_OBSERVER_APP_ID = 'com.example.app'

pnpm rn-observe launch
pnpm rn-observe observe
pnpm rn-observe understand-screen
pnpm rn-observe ui-model
pnpm rn-observe tap --test-id buy-button
pnpm rn-observe performance
pnpm rn-observe diagnose

Artefakte und SQLite-Daten werden unter <projectRoot>/.artifacts/ erstellt; große Binärdateien werden nie in MCP-Antworten eingebettet.

Deterministische Demo

pnpm --filter @rn-agent-observer/demo-expo android -- --device <device-name>

Die Demo enthält PerformanceLab, NetworkLab, RenderLab, AnimationLab, ErrorLab und VisualLab. NetworkLab verwendet interne Fixtures (0/500/2000ms und HTTP 503) und hängt daher nicht von Internetdiensten ab. PerformanceLab meldet seinen absichtlichen 100ms-Long-JS-Task präzise über die Instrumentierung.

MCP

pnpm mcp:check
pnpm mcp:start

Der Server spricht stdio. Client-Konfiguration und die vollständige Liste der 45 Tools finden Sie in docs/protocol.md.

Integration für KI-Agenten

Es gibt drei Möglichkeiten, wie Agenten (OpenCode/Claude Code/Cursor/Codex...) den Observer nutzen können:

1. MCP-Server (empfohlen — strukturierte Tools)

{
  "mcpServers": {
    "rn-agent-observer": {
      "command": "node",
      "args": [
        "C:\\abs\\rn-agent-observer\\packages\\mcp-server\\dist\\server.js"
      ],
      "env": {
        "RN_OBSERVER_PROJECT_ROOT": "C:\\path\\to\\expo-app",
        "RN_OBSERVER_DEVICE_ID": "emulator-5554"
      }
    }
  }
}

2. Als Skill installieren (bringt dem Agenten den Debug-Workflow über CLI bei)

npx skills add GinzaTech/rn-agent-observer

Der Skill liegt unter skills/rn-agent-observer/SKILL.md — er lehrt den Agenten die Schleife observe -> understand-screen -> reproduce -> diagnose -> fix -> understand-screen -> compare, wie man Metriken ehrlich liest und häufige Fehler behebt. Nach der Installation genügt „debug app X, die laggt", und der Agent weiß automatisch, rn-observe zu verwenden.

3. AGENTS.md (wenn der Agent direkt in diesem Repo arbeitet) — bereits im Root vorhanden; Agenten lesen es automatisch.

Alle drei Wege können kombiniert werden: Skill/AGENTS.md lehrt den Workflow, MCP bietet direkt aufrufbare Tools.

Dokumentation

Aktuelle Grenzen

  • Android/Windows ist das einzige unterstützte Ziel von Observer 2.4.0.

  • ADB hat kein vertrauenswürdiges JS-FPS-Signal; das Feld wird als available: false zurückgegeben — Werte werden nie geraten.

  • JS-Blocking, Route, React-Renders und Netzwerk-Metadaten erfordern Entwicklungs-Instrumentierung in der App.

  • CDP-Funktionen (devtools-export, devtools-profile) und Netzwerk pro Anfrage (metro-network) benötigen ein laufendes Metro und eine App, die mit Metro verbunden ist (adb reverse tcp:8081 tcp:8081); sie können nicht verwendet werden, während eine andere React-Native-DevTools-Sitzung die Verbindung hält.

  • reload --fast verwendet CDP Page.reload (nur JS) und fällt automatisch auf force-stop zurück, wenn Metro nicht verfügbar ist.

  • Apps ohne Instrumentierung: Verwenden Sie metro-network (CDP), app-state (Vordergrund-Activity, PID) und device-network (Byte-Zähler auf Geräteebene, nicht der App zugeordnet) als Fallback-Evidenz.

  • record (screenrecord) ist von Android auf 180s pro Clip begrenzt.

  • Perfetto-Tracing wird auf Android unterstützt; tiefgehende Trace-Analyse bleibt in Perfetto UI/Android Studio.

  • Observer-CDP-Befehle werden über Prozesse hinweg in die Warteschlange gestellt; externes React Native DevTools muss weiterhin geschlossen sein, da es nicht am Observer-Lock teilnimmt.

  • session stop schreibt automatisch ein Replay; Session-Refs überstehen Reorder/Scroll; fehlende Sessions erzeugen EVIDENCE_NOT_RECORDED.

  • understand-screen/MCP understand_screen gibt die instrumentierte Route zurück, wenn verfügbar, Screen-State, Headline, Text/Action-Refs, UI-Findings und Screenshot/UI-Tree-Evidenz; wiederholte Aufrufe erkennen unverändertes Laden. Die Klassifizierung ist heuristisch und Textfeld-Werte werden immer redigiert.

  • ui-model/MCP runtime_ui_model parst TSX mit dem TypeScript-AST für Komponente + file:line und korreliert dann mit Instrumentierung und nativem Baum. Es unterscheidet rendered, visible/offscreen/hidden/unmounted/flattened-or-unobserved, enabled und canPress mit Begründung.

  • Das nur für die Entwicklung gedachte Babel-Plugin fügt automatisch einen quellbasierten testID hinzu und umschließt onPress; Session-Stop erfasst Interaktionen start/success/error und übernimmt Taps mit testID ins Replay. Handler-Argumente, Props und Eingabewerte werden nie aufgezeichnet.

  • Netzwerk-Bodies werden standardmäßig nicht erfasst. Das Nur-Entwicklungs-Opt-in verwendet Fail-Closed-Allowlists und sollte weiterhin auf Fixtures beschränkt bleiben.


RN Agent Observer (English)

RN Agent Observer 2.4.0 is a local runtime observability bridge for React Native/Expo. It uses one shared TypeScript core behind both a CLI and an MCP server, drives Android through ADB/UIAutomator, receives telemetry from development instrumentation, exports console/exceptions/heap/JS CPU profiles through Metro's Chrome DevTools Protocol, captures per-request network traffic without app instrumentation, produces structured screen understanding (state/headline/actions/UI findings) for agents, provides session-stable ref snapshots + diffs + automatically recorded replay scripts, records on-screen video, persists sessions in SQLite, and keeps screenshots/traces/UI trees as on-disk artifacts.

The current release completes Android v1 on Windows: 45 MCP tools, the matching CLI, an Expo demo app with deterministic labs, transparent heuristic diagnosis, and pixel + structural UI comparison.

Requirements

  • Node.js 22.12 or newer

  • pnpm 9.6

  • Android Platform Tools (adb)

  • An Android emulator or physical device with USB debugging enabled

  • An Expo development build if you need app-specific telemetry

Quick Start

pnpm install
pnpm check
adb devices -l
pnpm rn-observe --help
pnpm mcp:check

Point the observer at your Expo/React Native app:

$env:RN_OBSERVER_PROJECT_ROOT = 'C:\path\to\expo-app'
$env:RN_OBSERVER_DEVICE_ID = 'emulator-5554'
# Optional when app.json contains expo.android.package
$env:RN_OBSERVER_APP_ID = 'com.example.app'

pnpm rn-observe launch
pnpm rn-observe observe
pnpm rn-observe understand-screen
pnpm rn-observe ui-model
pnpm rn-observe tap --test-id buy-button
pnpm rn-observe performance
pnpm rn-observe diagnose

Artifacts and SQLite data are created under <projectRoot>/.artifacts/; large binaries are never embedded in MCP responses.

Deterministic demo

pnpm --filter @rn-agent-observer/demo-expo android -- --device <device-name>

The demo ships PerformanceLab, NetworkLab, RenderLab, AnimationLab, ErrorLab, and VisualLab. NetworkLab uses internal fixtures (0/500/2000ms and HTTP 503) so it never depends on Internet services. PerformanceLab reports its intentional 100ms long JS task precisely through instrumentation.

MCP

pnpm mcp:check
pnpm mcp:start

The server speaks stdio. Client configuration and the full list of 45 tools are documented in docs/protocol.md.

Documentation

AI agent integration

Three ways for agents (OpenCode/Claude Code/Cursor/Codex...) to use the observer:

1. MCP server (recommended — structured tools)

{
  "mcpServers": {
    "rn-agent-observer": {
      "command": "node",
      "args": [
        "C:\\abs\\rn-agent-observer\\packages\\mcp-server\\dist\\server.js"
      ],
      "env": {
        "RN_OBSERVER_PROJECT_ROOT": "C:\\path\\to\\expo-app",
        "RN_OBSERVER_DEVICE_ID": "emulator-5554"
      }
    }
  }
}

2. Install as a skill (teaches the agent the debugging workflow via CLI)

npx skills add GinzaTech/rn-agent-observer

The skill lives at skills/rn-agent-observer/SKILL.md — it teaches the observe -> understand-screen -> reproduce -> diagnose -> fix -> understand-screen -> compare loop, how to read metrics honestly, and common failure recovery. After installing, just say "app X feels laggy" and the agent knows to reach for rn-observe.

3. AGENTS.md (when the agent works inside this repo) — already present at the repo root; agents read it automatically.

All three can be combined: the skill/AGENTS.md teach the workflow, MCP provides directly callable tools.

Current boundary

  • Android/Windows is the only supported target of Observer 2.4.0.

  • ADB has no trustworthy JS FPS signal; the field is returned as available: false — values are never guessed.

  • JS blocking, route, React renders, and network metadata require development instrumentation inside the app.

  • CDP features (devtools-export, devtools-profile, metro-network) need Metro running for the right app and the app connected to it (adb reverse tcp:8081 tcp:8081); they cannot attach while another React Native DevTools session holds the connection.

  • reload --fast uses CDP Page.reload (JS-only) and automatically falls back to force-stop when Metro is unavailable.

  • Observer CDP commands queue across processes; external React Native DevTools must still be closed because it does not participate in the observer lock.

  • session stop automatically writes a replay, session refs survive reorder/scroll, and missing sessions produce EVIDENCE_NOT_RECORDED.

  • understand-screen/MCP understand_screen returns the instrumented route when available, screen state, headline, text/action refs, UI findings, and screenshot/UI-tree evidence; repeated calls detect unchanged loading. Classification is heuristic and text-field values are always redacted.

  • ui-model/MCP runtime_ui_model parses TSX with the TypeScript AST for component + file:line, then correlates source with instrumentation and the native tree. It distinguishes rendered, visible/off-screen/hidden/unmounted/flattened-or-unobserved, enabled, and evidence-backed canPress states.

  • The development-only Babel plugin injects a source-derived testID and wraps onPress; session stop collects interaction start/success/error and promotes testID taps into replay. Handler arguments, props, and input values are never recorded.

  • Network body capture is off by default. Development-only opt-in uses fail-closed allowlists and should still be limited to fixtures.

  • Apps without instrumentation: use metro-network (CDP), app-state (foreground activity, PID), and device-network (device-level byte counters, not app-attributed) as fallback evidence.

  • record (screenrecord) is limited to 180s per clip by Android.

  • Perfetto tracing is supported on Android; deep trace analysis remains in Perfetto UI/Android Studio.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    This MCP server enables real-time debugging and inspection of running React Native apps, providing access to console logs, errors, network requests, navigation state, storage, and performance profiling.
    1
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A plugin-based MCP server for React Native runtime debugging, inspection, and automation via Chrome DevTools Protocol. Works with Expo, bare React Native, and any Metro + Hermes project without app code changes.
    822 npm
    85
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    An MCP server that gives AI agents hands-on control of a live React Native app, enabling UI taps, screenshots, UI/component trees, native logs, and JS/React profiling to debug, verify fixes, and diagnose performance issues.
    16
    4 npm
    MIT