Skip to content

chore: bump @metamask/device-mcp to ^0.9.0 - #116

Merged
cryptotavares merged 3 commits into
mainfrom
cryptotavares/mmcli-p1-51-device-mcp-0-9
Nov 20, 2026
Merged

cryptotavares merged 3 commits into
mainfrom
cryptotavares/mmcli-p1-51-device-mcp-0-9

Conversation

@cryptotavares

@cryptotavares cryptotavares commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the mm CLI v2 effort (ticket P1-51). Picks up the @metamask/device-mcp 0.9.0 release: MetaMask/device-mcp#54, MetaMask/device-mcp#59, MetaMask/device-mcp#60 and MetaMask/device-mcp#61.

Summary: Bump @metamask/device-mcp from ^0.8.0 to ^0.9.0. This turns on the persistent Hermes connection from #91 and the Android fixes for type "", dismiss-keyboard and covered taps. No core error mapping changes.

Problem

Core pins ^0.8.0. On 0.x, a caret range does not pick up 0.9.0. So with core 0.14.0 on Android:

  • device-mcp 0.8.0 has no HermesClient, so every mm cdp call opens its own socket.
  • A tap on a target under the keyboard or the Expo "Tools" button is sent. Android has no occlusion check.
  • mm type <field> "" fails with exit 4.
0.8.0  mm type --testid multichain-account-selector-search-input ""
       exit 4  MM_TYPE_FAILED  "Operation failed: Command failed: adb -s emulator-5554 shell input text …
               java.lang.IllegalArgumentException: Argument expected after "text""
0.8.0  mm click --testid fox-animation          (target under the keyboard)
       exit 0  {"clicked":true,…}               (the tap was sent)

Solution

Bump the range and type the persistent client against the real HermesClient class. Core now requires 0.9.0, so the feature check for an older device-mcp that #91 added is removed. A call with another Metro port or app id still uses a one-shot connection, so the session client is never retargeted.

flowchart TD
    A["mm cdp"] --> B{"session Metro port<br/>and app id?"}
    B -->|yes| C["one HermesClient per session<br/>socket opened once, reused"]
    B -->|"per-call override"| D["runHermesCdp: one-shot socket"]
    T["mm click (Android)"] --> H{"device-mcp 0.9.0 hit test:<br/>target covered?"}
    H -->|no| P[tap sent]
    H -->|"keyboard, --dismiss-keyboard"| K["dismissKeyboard (verified), tap again"]
    H -->|"keyboard or overlay"| X["MM_TARGET_OBSCURED, exit 4.<br/>Nothing is tapped."]

    classDef new fill:#fff3cd,stroke:#d39e00
    classDef stop fill:#f8d7da,stroke:#c82333
    class C,H,K new
    class X stop
Loading

Yellow boxes are new. Red boxes stop the tap.

What changes

Live run on the Android emulator and the iOS simulator (dev build, Metro 8085). Before: npm core 0.14.0 with device-mcp 0.8.0. After: this branch with device-mcp 0.9.0.

Check Before After
Android mm cdp Runtime.evaluate 1+1, 10 calls, totalMs p50 / p95 49 / 94 ms, no socket kept 4 / 1523 ms (calls 2–10: 3 / 24 ms). One socket to Metro, same local port after call 1 and call 10
iOS, same bench, login screen 6 / 17 ms 3 / 7 ms, one socket reused
mm type <account search> "" after zz exit 4 MM_TYPE_FAILED, field z exit 0 textLength: 0, field shows its placeholder
mm dismiss-keyboard, keyboard up 1/1 exit 0, hidden (not verified by device-mcp) 3/3 exit 0, mInputShown true → false (verified by device-mcp)
mm click --testid fox-animation, under the keyboard exit 0, tap sent exit 4 MM_TARGET_OBSCURED: … covered at (540, 1959) by the keyboard: android.widget.FrameLayout. Nothing was tapped. …
Same click with --dismiss-keyboard — exit 0 keyboardDismissed: true
mm click --testid navbar-hamburger-menu-button, under "Tools" — exit 4 MM_TARGET_OBSCURED: … by android.view.View around android.widget.ImageView label="Tools"
iOS describe-screen on login — 17 nodes, 9 test IDs, no warnings field

The first after call (2742 ms) ran about 3 s after the unlock, while wallet home was still loading. On quieter screens a new client takes 50–135 ms for its first call.

Decisions for reviewers

Decision Reason
Replace the hand-written HermesClientLike and HermesClientConstructor with device-mcp's HermesClient type 0.9.0 exports the class. Its metroPort, appId, isConnected, send(method, params, { timeoutMs }) and close() match the old shape. send returns HermesCdpResult, which has the same shape as CdpOutcome.
Remove the run-time typeof HermesClient === 'function' check and the "older device-mcp" fallback Core declares ^0.9.0 as a dependency, and every 0.9.x exports HermesClient. The check only existed because #91 merged before 0.9.0 was out. Forcing an older device-mcp against core's range is not supported.
No trackContexts and no listeners 0.9.0 sends Runtime.enable only when trackContexts is true (default false). Core passes { metroPort, appId, pinnedDeviceId, onPin } only. So core sends no Runtime.enable.
No error mapping changes The Android TargetObscuredError uses code: 'TARGET_OBSCURED' and keyboard: true. classifyInteractionError and isKeyboardObscured already read these fields. The new Keyboard still shown after ESCAPE and BACK. … error is a plain Error. dismissKeyboardTool reports it as MM_DEVICE_ACTION_FAILED.
Do not surface SnapshotResult.warnings The core part of P1-38 is a separate ticket. #snapshotApp reads only hierarchy.
chore:, not feat: Core's API does not change. The new behaviour comes from device-mcp.

Review guide

Read the files in this order:

# File What to check
1 package.json, yarn.lock ^0.9.0. yarn dedupe leaves one device-mcp entry.
2 src/platform/mobile-platform-driver.ts #hermesClient: HermesClient, #getHermesClient (no feature check), the one-shot path for per-call overrides
3 Tests Real TargetObscuredError in mobile-platform-driver.test.ts and error-classification.test.ts. The dismissKeyboard error in device.test.ts. A snapshot with warnings in captureScreen.
4 README.md, SKILL.md Version text. Android hit test. dismiss-keyboard check.

Consumer changes

Mobile and Extension bump @metamask/device-mcp to ^0.9.0 with core 0.15.0. Both copies matter on Mobile:

  • The consumer creates the backend from its own device-mcp. The Android fixes (type "", verified dismiss-keyboard, MM_TARGET_OBSCURED) come from that copy.
  • Core resolves HermesClient from its own location. With only core bumped, the persistent client works but the Android fixes do not.
Testing
  • yarn build, yarn lint (exit 0) and CI=1 yarn test pass: 65 files, 2443 tests, no type errors. Coverage 98.21 / 96 / 97.85 / 98.3. The floors in vitest.config.mts do not change.
  • Live run (real-funds devices, read-only screens only):
    • Core and the app backend both resolved node_modules/@metamask/device-mcp 0.9.0. HermesClient was a function.
    • Socket reuse: lsof on the daemon showed one ESTABLISHED socket to 8085 with the same local port across 30 calls. mm hermes-targets reported connected: true and sessionMetroPort: 8085.
    • Same-moment client vs one-shot, 5 pairs each: quiet app, reused 1–2 ms vs one-shot 47–50 ms. Busy app, reused 33–53 ms vs one-shot 107–172 ms.
    • The Expo "Tools" button also covers the Social onboarding close button. The click was refused with MM_TARGET_OBSCURED.
  • Extension smoke (e2e fixture wallet, headless): launch, describe-screen and cleanup exit 0.
Docs changed
  • README.md: core depends on ^0.9.0, and the consumer must create its backend from the same range. The session keeps one Hermes connection.
  • SKILL.md: Android hit-tests taps with device-mcp 0.9.0. Android dismiss-keyboard fails with MM_DEVICE_ACTION_FAILED when the keyboard stays up. The persistent Hermes connection is described without a version condition.

Type the persistent Hermes client against device-mcp's HermesClient and
test the 0.9.0 Android error shapes (TargetObscuredError with keyboard,
the verified dismissKeyboard failure) and snapshot warnings.
@socket-security

socket-security Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​device-mcp@​0.8.0 ⏵ 0.9.088 -4100100 +197 +280

View full report

@socket-security

socket-security Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • @metamask/device-mcp@0.9.0

View full report

@cryptotavares
cryptotavares marked this pull request as ready for review November 20, 2026 12:39
@cryptotavares
cryptotavares requested a review from a team as a code owner November 20, 2026 12:39
…res device-mcp ^0.9.0

Read HermesClient straight from the typed device-mcp runtime. Keep the
one-shot path for a call whose metroPort or appId differs from the session
target, so the persistent client is never retargeted.

The tests force that one-shot path with a per-call metroPort instead of
modelling a device-mcp without HermesClient. Drop the matching compatibility
prose from the README and SKILL.md.
@cryptotavares

Copy link
Copy Markdown
Collaborator Author

@SocketSecurity ignore npm/@metamask/device-mcp@0.9.0

@cryptotavares
cryptotavares merged commit 4a04c80 into main Nov 20, 2026
27 checks passed
@cryptotavares
cryptotavares deleted the cryptotavares/mmcli-p1-51-device-mcp-0-9 branch November 20, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants