feat: add Hermes CDP tools for React Native runtime access#14
Open
cryptotavares wants to merge 1 commit into
Open
feat: add Hermes CDP tools for React Native runtime access#14cryptotavares wants to merge 1 commit into
cryptotavares wants to merge 1 commit into
Conversation
Add hermes_cdp and hermes_targets MCP tools that speak Chrome DevTools Protocol to the React Native Hermes JS runtime via Metro's inspector proxy (iOS and Android). Includes standalone HermesSession state for Metro port, app bundle ID, and device pinning, plus target discovery, selection, and ambiguity handling.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current state of things and why does it need to change?
The MCP server can drive native UI automation (idb/adb/Appium) but has no
way to inspect the app's JavaScript layer. For a React Native app, a large
share of state and logic lives in the Hermes JS runtime, which native automation
cannot reach. Agents debugging or validating app behavior have no way to
evaluate JavaScript, read runtime state, or diagnose the JS layer.
What is the solution your changes offer and how does it work?
Adds two MCP tools that speak raw Chrome DevTools Protocol
(CDP) to the React Native Hermes runtime via Metro's inspector proxy — on
both iOS and Android (the transport is identical HTTP/WebSocket to Metro; only
the default
appIddiffers):hermes_cdphermes_targetsHow it works: the app's Hermes runtime connects out to Metro; Metro exposes
debuggable targets over
http://localhost:<metroPort>/jsonwith a per-targetwebSocketDebuggerUrl. The server discovers targets, selects the right one, andspeaks real CDP over that WebSocket. A standalone
HermesSessionholds theresolved Metro port, expected app bundle id, and the pinned device id
(precedence: per-call param > env var > default), decoupled from
DeviceBackend.Safety model — a single Metro can host multiple apps/simulators, so five
fail-closed checks run before executing CDP:
appIdmatch (no substring, notargets[0]fallback).HermesInternalidentity probe before the user's method.reactNative.logicalDeviceIdafter first success.ws:protocol, loopback host, matching port).Destructive methods (
Runtime.terminateExecution,Inspector.detached) areblocked, and the synthetic legacy page is filtered out.
Configuration:
HERMES_APP_ID/appIdparam (defaultsio.metamask.MetaMaskiOS,
io.metamaskAndroid) andHERMES_METRO_PORT/metroPortparam (default8081). Requires a DEBUG build with Metro running; Node 20 needsNODE_OPTIONS="--experimental-websocket".Includes full unit test coverage (session resolution, CDP core, tool handlers)
and README + CHANGELOG updates.