ohos-chrome-devtools-mcp
v0.1.2
Published
Thin wrapper that bridges OpenHarmony ArkWeb (via hdc fport) to chrome-devtools-mcp. The OHOS counterpart of @modelcontextprotocol/chrome-devtools.
Maintainers
Readme
ohos-chrome-devtools-mcp
Thin wrapper that lets chrome-devtools-mcp drive the ArkWeb browser on an OpenHarmony / HarmonyOS device. The OHOS counterpart of the upstream Chrome DevTools MCP server.
The MCP surface — tools, behaviour, output formats — is the upstream chrome-devtools-mcp verbatim. This wrapper exists only to do the OHOS-specific hdc dance:
- Connect to the device (auto-discovery via
hdc tconn, or a manual paste fallback). - Locate the ArkWeb browser process and its
@webview_devtools_remote_<pid>abstract socket. - Forward that socket to a local TCP port with
hdc fport. - Spawn
chrome-devtools-mcpwith--browserUrl=http://127.0.0.1:<port>and pipe its stdio straight through.
When the wrapper exits, the hdc fport rule is cleaned up.
Install
npm i -g ohos-playwright ohos-chrome-devtools-mcp chrome-devtools-mcpohos-playwright and chrome-devtools-mcp are peer dependencies — npm 7+ installs them alongside automatically when you install this package globally.
MCP client configuration
{
"mcpServers": {
"ohos-chrome-devtools": {
"command": "ohos-chrome-devtools-mcp",
"args": []
}
}
}Any additional flags accepted by the upstream chrome-devtools-mcp can be appended to args — they are forwarded as-is, with a short blocklist for flags that would conflict with the connect-only flow (see Stripped flags).
How it differs from chrome-devtools-mcp
| | upstream chrome-devtools-mcp | this wrapper |
|---|---|---|
| Target browser | Chrome (launched locally) | ArkWeb on an OHOS device, over hdc |
| Setup | Puppeteer launches Chrome | ohos-playwright/setup (hdc connect + fport) |
| Connection | --browserUrl / --wsEndpoint / --channel | always connects via --browserUrl (injected) |
| Tool surface | full upstream API | identical — wrapper does not modify it |
Stripped flags
These flags would make chrome-devtools-mcp ignore the OHOS device and either launch a local Chromium or connect somewhere unintended. The wrapper silently drops them with a stderr note:
--browserUrl(we set this from the device endpoint)--wsEndpoint--channel--userDataDir--executablePath--isolated
Environment
Configuration is inherited from ohos-playwright. The most useful variables:
| Variable | Default |
|---|---|
| OHOS_PW_HDC | /data/service/hnp/bin/hdc |
| OHOS_PW_BUNDLE | com.huawei.hmos.browser |
| OHOS_PW_LAUNCH_URL | about:blank |
| OHOS_PW_AUTO_CONNECT | auto (set 0 to skip auto-connect) |
| OHOS_PW_INFO_PATH | <tmpdir>/ohos-playwright-cdp.json |
Wrapper-specific overrides (rarely needed):
| Variable | Purpose |
|---|---|
| OHOS_CDT_SETUP | absolute path to a custom setup module |
| OHOS_CDT_TEARDOWN | absolute path to a custom teardown module |
| OHOS_CDT_BIN | absolute path to a chrome-devtools-mcp bin to spawn |
Troubleshooting
Cannot resolve "ohos-playwright/setup"— install ohos-playwright (npm i -g ohos-playwright) or setOHOS_CDT_SETUP.Cannot resolve "chrome-devtools-mcp/package.json"— install upstream (npm i -g chrome-devtools-mcp) or setOHOS_CDT_BIN.ohos-playwright setup finished but ... was not written— usually a stalehdc tconn/ sandbox-blocked device. Runhdc list targetsto check.- The upstream
chrome-devtools-mcpserver writes its own diagnostics to stderr; check stderr first when a tool fails.
License
MIT
