h5-devtools-mcp

v0.1.2
io.github.xianguoGou/h5-devtools-mcp Checked 4 days ago Published 1 month ago

Debug H5 pages inside Android app WebViews: console logs, exceptions, run JS.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_targets List WebView pages

List debuggable H5 pages running inside Android WebViews (and Chrome) on connected devices. Returns a target id for each page to pass to attach.

attach Attach to a page

Connect to a WebView page and start buffering its console output and uncaught exceptions (the last 1000 entries). Recent messages the engine still holds are replayed on attach, but attach before reproducing an issue to be sure nothing is missed. Only observes the page: it is not reloaded or modified. May be refused while Chrome DevTools (chrome://inspect) is attached to the same page; close it and retry. Calling it again for an attached page reuses the existing session.

ParameterTypeDescription
target_id *stringTarget id from list_targets, e.g. "<serial>/<socket>/<page id>"

get_console Read console output

Read buffered console messages, uncaught exceptions and browser log entries from an attached page. Requires attach first; only entries captured since attach (plus what attach replayed) are available. Returns the most recent matching entries. Pass since_seq from a previous call to get only new entries.

ParameterTypeDescription
exclude_keywordsarrayDrop entries whose text or location contains any of these (case-insensitive), e.g. ["google-analytics", "doubleclick"]
keywordstringCase-insensitive substring match on message text and location
levelsarrayOnly these levels, e.g. ["warn", "error"]
limitintegerMax entries to return (default 50)
since_seqintegerOnly entries with seq greater than this
target_idstringDefaults to the most recently attached page

evaluate_js Evaluate JavaScript in a page

Run a JavaScript expression in an attached page and return its result. Plain objects/arrays come back as JSON (so nested Map/Set/DOM values show as {}); other values (DOM nodes, Map, Set, Error, window) as a short description. Promises are awaited. For multiple statements or await, wrap them: (async () => { ... })(). Runs with the page's full privileges, so it can read cookies/storage and change page state.

ParameterTypeDescription
expression *stringJavaScript expression to evaluate
target_idstringDefaults to the most recently attached page

detach Detach from a page

Disconnect from a page and discard its buffered console entries. The page itself keeps running and is not closed; call attach again to resume capturing. Use it to stop capturing or to start over with an empty buffer.

ParameterTypeDescription
target_idstringDefaults to the most recently attached page