Skip to content

Latest commit

 

History

History
127 lines (86 loc) · 11.2 KB

MCP.md

File metadata and controls

127 lines (86 loc) · 11.2 KB

DevMark MCP bridge

DevMark's MCP mode is an optional local developer-control layer for Arc on macOS. It lets an MCP client inspect and control normal web tabs through Chromium's debugging protocol while keeping the page annotator available as a separate feature. Its canonical registered MCP server name is devmark-arc.

Codex may normalize that hyphen to an underscore in callable tool namespaces. That does not rename the registered server: resource reads must use read_mcp_resource with server: "devmark-arc". Using server: "devmark_arc" returns an unknown-server error.

Architecture

MCP client (stdio)
  -> DevMark MCP adapter
  -> authenticated owner-only Unix socket
  -> Arc-launched Native Messaging host
  -> DevMark MV3 service worker
  -> chrome.debugger / Chrome DevTools Protocol
  -> approved Arc tabs

There is no listening TCP port. Arc authorizes only the installed DevMark extension origin to launch com.devmark.bridge, and the MCP adapter must also authenticate with the random secret produced by the installer.

Consent and session lifecycle

MCP browser access is disabled after every Arc launch and extension reload. It can only be enabled from the DevMark popup. The confirmation names the sensitive capabilities being granted: all normal tabs, raw network headers and bodies, browser storage, page and console data, full input control, navigation, and arbitrary JavaScript evaluation.

While enabled, DevMark attaches supported current tabs and automatically attaches supported future tabs. It keeps control across ordinary HTTP(S) navigation. Discarded tabs are not awakened merely to attach; they attach when activated.

The following targets are never supported:

  • incognito tabs;
  • Arc, Chromium, DevTools, extension, and Web Store pages;
  • local file:, data:, and javascript: URLs; and
  • Arc's sidebar, Spaces, command bar, and other browser chrome.

Select Stop at any time. Stopping detaches the debugger, invalidates all session and node references, and removes volatile network, console, and temporary artifact data. It does not delete screenshots already saved by the annotation feature.

MCP surface

The server exposes typed tools rather than a general-purpose raw CDP command:

  • status and tab management: browser_status, browser_tabs, browser_session_stop, browser_tab_open, browser_tab_activate, browser_tab_close;
  • inspection: browser_snapshot, browser_console, browser_network, browser_network_body, browser_storage, browser_screenshot, browser_annotations;
  • artifact handling: browser_artifact_export;
  • responsive emulation: browser_device_set, browser_device_clear;
  • control: browser_click, browser_type, browser_press, browser_hover, browser_scroll, browser_navigate, browser_reload, browser_wait, browser_evaluate.

Tab-bound tools require the opaque sessionId returned by browser_tabs. Pointer actions accept one target form:

{ "nodeRef": "opaque snapshot node reference" }
{ "selector": "button.save", "frameId": "optional frame id" }
{ "x": 120, "y": 340 }

Typing and node screenshots require a {nodeRef} or {selector, frameId?} target; coordinate-only targets are rejected because they do not identify a focusable or capturable node.

Node references are bound to the current page epoch and become invalid after navigation or DOM replacement. A stale reference returns NODE_STALE; callers should take a new snapshot instead of guessing.

Device Preview and responsive emulation

Device Preview is also available directly from the extension popup for the current tab and does not require the MCP bridge. Manual preview and MCP control share one debugger attachment when both are active; stopping MCP invalidates its session IDs without closing a manually opened preview.

browser_device_set accepts either a named preset or custom dimensions. Presets are desktop-4k (1920x1080 CSS at 2x DPR, producing 3840x2160 output), desktop-4k-native (3840x2160 CSS at 1x DPR), desktop-fhd (1920x1080), laptop-l (1440x900), laptop-s (1024x768), ipad-pro-11 (834x1194), ipad-mini (768x1024), iphone-15 (390x844), pixel-7 (412x915), and iphone-se (375x667). Phone and tablet profiles enable mobile layout and touch; desktop and laptop profiles do not. Orientation changes swap logical width and height.

The recommended desktop-4k profile is labeled 4K Display and models a readable HiDPI 4K display: 1920x1080 CSS pixels at 2x DPR, producing 3840x2160 output. desktop-4k-native is labeled 3840px CSS (Advanced); use it only when the page must receive a true 3840px-wide CSS viewport. Fitting that advanced viewport into an ordinary Arc window makes the live page appear very small and does not make fixed-width sites expand.

Custom axes are limited to 240-3840 CSS pixels, DPR to 1-4, and the resulting width x height x DPR^2 to 40 million pixels. Fit may be auto, fill, 0.25, 0.5, 0.75, or 1. The canonical wire value auto appears in the UI as Entire viewport (Contain): it keeps the full live viewport visible and may leave unused Arc space when aspect ratios differ. fill covers the available host surface while scaling down, cropping overflow from the right or bottom as necessary; it is capped at 1 (100%), so smaller previews are not enlarged. Numeric fits retain their existing fixed-scale behavior. Fit affects only the live preview; screenshot artifacts always contain the complete viewport at the native emulated dimensions and report the active emulation metadata.

Device identity is explicit but has profile-aware defaults. Named phone and tablet presets default emulateDeviceIdentity to true; desktop and laptop presets plus custom desktop and custom-mobile profiles default it to false. MCP callers can pass "emulateDeviceIdentity": false to a named mobile preset for mobile layout and touch without changing Arc's native identity. A custom-mobile profile remains native and layout-only unless the caller passes "emulateDeviceIdentity": true. The extension UI exposes that opt-in as Mobile + identity.

Pixel identity follows the current Chromium DevTools profile for Android 13 and overrides both the legacy user agent (UA) and User-Agent Client Hints (UA-CH). Apple phone and tablet identities follow current Chromium DevTools device data for iOS/iPadOS 18.5: DevMark sends a Safari-style UA together with userAgentMetadata platform, model, and mobile values. Any transition between native and emulated identity reloads the page exactly once so navigation headers and page JavaScript agree. The chrome.debugger API cannot call Browser.getVersion; DevMark instead derives the Chromium version once from an isolated native navigator.userAgent snapshot before applying an override.

Identity emulation changes what the page observes; it does not change Arc's underlying Chromium rendering engine into Android Chrome or Mobile Safari. browser_device_clear restores the native Arc user agent and client hints and reloads once when an identity override was active.

browser_device_clear is idempotent: it sends the CDP reset even if DevMark's local state already says emulation is inactive, restores native Arc identity when needed, waits for the native Arc viewport to stabilize, and returns short reset metadata with the observed viewport, native tab surface, whether dimensions stayed unchanged, and whether a zero-metrics compatibility fallback was needed. Identity restoration performs one reload; a clear with no active identity override does not add an identity reload. Unchanged dimensions can be correct when a preset such as Laptop L matches Arc's native 1440x900 content viewport. Verification is conservative: non-100% page zoom can make surfaceMatched and verified false even after Chromium accepted the reset.

{
  "sessionId": "opaque-session",
  "profile": {
    "kind": "preset",
    "presetId": "iphone-15",
    "orientation": "portrait"
  },
  "fit": "auto",
  "emulateDeviceIdentity": true
}

Resources provide status, tab data, buffered snapshots/console/network/annotations, and temporary large artifacts under devmark://... URIs. Reading devmark://artifact/{id} continues to return the existing base64 MCP resource while that volatile artifact is available.

browser_artifact_export saves an existing artifact's verified bytes directly to ~/Downloads without placing a base64 string or blob in the tool result. Pass either its devmark://artifact/{id} URI or the artifact ID:

{
  "artifact": "devmark://artifact/opaque-id",
  "filename": "google-background.png",
  "revealInFinder": false
}

filename is optional and must be a single leaf name. Path separators and traversal syntax are rejected, unsafe characters within an otherwise valid leaf are sanitized, and an existing destination is never overwritten. A name collision returns PERMISSION_DENIED; a missing or expired source returns BODY_UNAVAILABLE. revealInFinder defaults to false. Success returns only savedPath, mimeType, byteSize, sha256, and finderOpened. Exporting does not consume or alter the volatile resource, and the saved file remains on the device after that resource expires or the MCP session stops.

Capture limits

  • Console: 2,000 entries or 5 MiB per attached tab.
  • Network: 2,000 requests or 20 MiB of metadata per attached tab.
  • All tabs combined: 10,000 console entries/25 MiB and 10,000 network entries/100 MiB.
  • Retention: 30 minutes or until access is stopped.
  • Inline body: 512 KiB; larger payloads become temporary resources.
  • Artifact: 50 MiB each and 250 MiB per session.
  • Snapshot: 5,000 nodes by default and 20,000 at most.
  • JavaScript expression: 64 KiB.
  • Typed text: 200,000 characters and 192 KiB after JSON escaping.

Network capture begins only after a tab attaches. Reload the page after enabling MCP when the initial page load must be recorded. Chromium may evict response bodies or make streamed/downloaded bodies unavailable even when request metadata remains present.

For networkidle, WebSocket handshakes and EventSource responses count while opening, but established long-lived streams do not keep the page permanently busy. Their bounded frame/message metadata continues to be captured.

The aggregate network limits above cover DevMark's normalized JavaScript metadata, not Chromium's internal CDP response-body buffers. Chromium allocates those per attached root or child target, so pages with many frames or workers can transiently use more browser memory while capture is enabled. Stop MCP access when raw body capture is no longer needed.

Snapshot output is assembled within an 8 MiB payload budget and reports when it was truncated. Chromium's DOM and accessibility commands can still transiently return a larger raw tree before DevMark normalizes it, so use a smaller maxDepth/maxNodes on unusually large pages.

Expected interruptions

Opening DevTools can take over the same debugger target. DevMark reports DEBUGGER_DETACHED and does not fight DevTools for control. Close DevTools before retrying. Closing a tab, navigating a target while an operation is in progress, stopping the session, or restarting Arc also invalidates its session-scoped handles.

Mutating operations such as clicks, typing, navigation, and evaluation are not automatically retried after an uncertain timeout. This prevents duplicate actions.