H5 Devtools Mcp

io.github.xianguoGou由 GitHub 帳號 xianguoGou 發布v0.1.2更新於 Nov 4, 2026

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

已驗證STDIO僅桌面瀏覽器自動化開發者工具

概覽

AI 產生的概覽

讓程式開發助理偵錯真實 Android 裝置上 WebView 內的 H5 頁面:列出頁面、讀取主控台記錄與例外,並執行 JavaScript。

可以做什麼
  • 列出已連線裝置上 Android WebView(及 Chrome)中可偵錯的 H5 頁面,包含應用程式套件、標題、URL 與可見性
  • 附加到某個頁面並開始緩衝其主控台輸出與未攔截例外
  • 讀取緩衝的主控台與例外項目,可依等級或關鍵字篩選,並支援增量取得
  • 在已附加的頁面中執行 JavaScript 運算式並回傳結果,Promise 會被等待
  • 從頁面分離,停止擷取並清空緩衝
適用情境
適合偵錯嵌入 Android 應用程式中的網頁,希望由助理查看記錄、例外或頁面狀態,而不必開啟 chrome://inspect。主要用於開發階段在實機上進行行動網頁偵錯。
執行需求
透過 npx 以 stdio 在本機執行。需要 Node.js 18+、PATH 中的 adb(或設定 ADB_PATH)、開啟 USB 偵錯的 Android 裝置,以及啟用 WebView 偵錯的應用程式。需在裝置上接受 USB 偵錯授權。
安裝前請注意
evaluate_js 以頁面完整權限執行,可讀取 cookie、儲存空間與權杖,並改變頁面狀態,應置於助理的工具權限確認之後。通常同一頁面只能附加一個偵錯工具,需關閉已開啟的 DevTools 視窗。v0.1 早期版本,僅支援 Android。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 H5 Devtools Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

h5-devtools-mcp

[npm version] [npm downloads] [license]

English | 简体中文

An MCP server that lets coding agents (Claude Code, Codex, Cursor…) debug H5 pages running inside Android WebViews on real devices — read console output and uncaught exceptions, and run JavaScript in the page, without opening chrome://inspect.

Status: v0.1, early. Android only.

How it works

Coding agent ──MCP (stdio)──▶ h5-devtools-mcp ──adb forward──▶ webview_devtools_remote_<pid> ──CDP──▶ WebView page

Every debuggable WebView exposes a Chrome DevTools Protocol endpoint on an abstract unix socket. The server discovers those sockets over adb (the same way chrome://inspect does), forwards them to local ports, and connects with CDP.

Requirements

  • Node.js 18+
  • adb on your PATH (or set ADB_PATH)
  • An Android device with USB debugging enabled
  • The app must enable WebView debugging (debug builds usually do):
java
WebView.setWebContentsDebuggingEnabled(true);

Setup

bash
# Claude Codeclaude mcp add h5-devtools -- npx -y h5-devtools-mcp

Other MCP clients (Cursor, Codex…) take the same command: npx -y h5-devtools-mcp.

From source

bash
git clone https://github.com/xianguoGou/h5-devtools-mcp.gitcd h5-devtools-mcpnpm install && npm run buildclaude mcp add h5-devtools -- node /absolute/path/to/h5-devtools-mcp/dist/index.js

Tools

ToolWhat it does
list_targetsList debuggable pages: app package, title, URL, visibility
attachConnect to a page and start buffering console output
get_consoleRead buffered entries, filtered by level / keyword / exclude_keywords, incrementally via since_seq
evaluate_jsRun a JavaScript expression in the page and return the result (promises are awaited)
detachDisconnect from a page

Output is designed to be token-cheap: compact one-line entries, long messages truncated, and since_seq so an agent only reads what's new instead of re-reading the whole buffer on every turn.

Example

> list_targets- id: R5CT1234/webview_devtools_remote_8812/3A1F…  app: com.example.app (pid 8812) on SM-S9180  title: "Order"  url: https://m.example.com/order
> get_console { "levels": ["error"] }#41 10:32:01.123 [error exception] TypeError: Cannot read properties of undefined (reading 'price')    at https://m.example.com/assets/index-8f2a.js:1:48213next since_seq: 57

Troubleshooting

  • "no debuggable WebView found" — the app hasn't enabled WebView debugging, or no WebView is alive yet. Open the H5 page first.
  • "debugger in use" — only one debugger can attach to a page. Close the chrome://inspect DevTools window.
  • "unauthorized" — accept the USB debugging prompt on the device.

Known limitations

  • Debugger-in-use detection is best-effort. It relies on /json/list omitting webSocketDebuggerUrl. Recent Chromium accepts several CDP clients per page, so attach may succeed alongside an open DevTools window; older WebViews may still refuse.
  • list_targets can take ~3s per unresponsive app. Sockets are queried one by one with a 3s timeout, and Android freezes background apps, so their WebView sockets stop answering. attach only re-checks the target's own socket and stays fast.
  • evaluate_js runs with the page's full privileges — it can read cookies, storage and tokens, and change page state. Keep it behind your agent's tool-permission prompt.
  • The e2e script expects port 9333 to be free. If a previous run left a headless Chromium behind, it attaches to that one; kill it first.

Development

The e2e test uses a fake adb and headless Chromium in place of a phone:

bash
npm run buildCHROME=/path/to/chrome npm run test:e2e

Roadmap

  • Discover devices and WebView pages
  • Console messages, uncaught exceptions, browser log entries
  • Network requests and responses
  • JSBridge call logging (configurable bridge shapes)
  • evaluate_js
  • screenshot
  • JSBridge mocking
  • iOS (WKWebView via WebKit Inspector Protocol)

License

MIT

來源:README.md,提交 ce0e832

工具

5

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.

輸入參數target_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.

輸入參數limitlevelskeywordsince_seqtarget_idexclude_keywords

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.

輸入參數target_idexpression必填

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.

輸入參數target_id

版本歷史

2
  1. v0.1.2最新Oct 21, 2026
  2. v0.1.1Oct 21, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分