feat(desktop): bundle chrome-devtools-mcp as dependency, eliminate npx requirement#1670
Merged
benjaminshafii merged 1 commit intodevfrom May 6, 2026
Merged
Conversation
…x requirement Instead of shelling out to npm exec (which requires npm/npx on PATH), the Electron main process now resolves the chrome-devtools-mcp binary directly from node_modules via createRequire. When the user connects Chrome DevTools MCP in the Electron app, the resolved absolute path is written to opencode.json as ["node", "<path>"], so OpenCode can spawn it without any external tool dependency. Changes: - Add chrome-devtools-mcp@0.17.0 as a dependency of @openwork/desktop - Add resolveChromeDevtoolsMcpBin IPC handler in Electron main process - Add resolveChromeDevtoolsMcpCommand() in mcp.ts for Electron runtime - Update connections store to resolve bundled bin before writing config - Rewrite shim to try bundled package first, npm exec as fallback - Remove Bun-compiled sidecar build from prepare-sidecar.mjs - Add isolated tests for bin resolution and command building
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
benjaminshafii
added a commit
that referenced
this pull request
May 6, 2026
…ixed) Re-implements both features with fixes for the issues found in #1670/#1671: Fixes from PR1 (chrome-devtools-mcp bundling): - Use 'node' string literal instead of process.execPath in the IPC handler — process.execPath in Electron is the Electron binary, not node, so OpenCode couldn't spawn the command - Fix args filter to only carry --prefixed flags (not -y from npx) - Fix mcp.add fallback path to use resolved command from mcpEntryConfig instead of the original entry.command Fixes from PR2 (embedded browser panel): - Guard against zero-dimension bounds on first render — skip browser.show() until the panel has non-zero dimensions, let ResizeObserver trigger the actual show - Defensive try/catch in destroyBrowserView for already-destroyed webContents Verified: - resolveChromeDevtoolsMcpBin returns ['node', '<abs-path>'] (not ['Electron', '<path>']) - All 17 existing tests pass - Electron app starts and loads successfully - CDP targets visible at the remote debugging port
benjaminshafii
added a commit
that referenced
this pull request
May 6, 2026
…e-implement * Revert "feat(desktop): add embedded browser panel with WebContentsView (#1671)" This reverts commit 610ae1c. * Revert "feat(desktop): bundle chrome-devtools-mcp as dependency, eliminate npx requirement (#1670)" This reverts commit fe9881b. * feat(desktop): bundle chrome-devtools-mcp + embedded browser panel (fixed) Re-implements both features with fixes for the issues found in #1670/#1671: Fixes from PR1 (chrome-devtools-mcp bundling): - Use 'node' string literal instead of process.execPath in the IPC handler — process.execPath in Electron is the Electron binary, not node, so OpenCode couldn't spawn the command - Fix args filter to only carry --prefixed flags (not -y from npx) - Fix mcp.add fallback path to use resolved command from mcpEntryConfig instead of the original entry.command Fixes from PR2 (embedded browser panel): - Guard against zero-dimension bounds on first render — skip browser.show() until the panel has non-zero dimensions, let ResizeObserver trigger the actual show - Defensive try/catch in destroyBrowserView for already-destroyed webContents Verified: - resolveChromeDevtoolsMcpBin returns ['node', '<abs-path>'] (not ['Electron', '<path>']) - All 17 existing tests pass - Electron app starts and loads successfully - CDP targets visible at the remote debugging port * feat(desktop): auto-inject chrome-devtools MCP into opencode.json on engine start When the OpenCode engine starts in the Electron desktop app, ensureOpencodeConfig now automatically adds a chrome-devtools MCP entry to opencode.json if one doesn't already exist. The command uses the bundled chrome-devtools-mcp package (['node', '<abs-path>']) so no npm/npx is needed at runtime. This mirrors what Tauri's ensure_workspace_files() does in files.rs for the starter preset, making Control Chrome a zero-setup default for all Electron workspaces. * fix(desktop): seed chrome-devtools MCP at workspace creation time ensureOpencodeConfig in runtime.mjs only runs when the OpenCode engine starts, which happens asynchronously after the workspace is selected. New workspaces were left without a chrome-devtools entry because the engine hadn't started yet. Fix: call seedChromeDevtoolsMcp(folderPath) directly inside the workspaceCreate IPC handler so the config is written synchronously during workspace creation. The runtime.mjs ensureOpencodeConfig remains as a backup for workspaces created before this change. Verified: created a workspace via IPC, confirmed opencode.jsonc contains chrome-devtools with ['node', '<bundled-bin-path>']. * fix(desktop): migrate legacy npx/bare chrome-devtools commands to bundled node path Existing workspaces created by Tauri or older Electron versions have chrome-devtools MCP entries with npx-based or bare-binary commands like ['npx','-y','chrome-devtools-mcp@latest'] or ['chrome-devtools-mcp']. Both seedChromeDevtoolsMcp (main.mjs, runs at workspace creation) and ensureOpencodeConfig (runtime.mjs, runs at engine start) now detect these legacy commands and migrate them to the bundled ['node', path] command. User-customised commands (absolute paths, etc.) are preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chrome-devtools-mcp@0.17.0as a direct dependency of@openwork/desktop, so the Electron app no longer requiresnpm/npxon PATH to run Chrome DevTools MCP.createRequireand exposes it through a newresolveChromeDevtoolsMcpBinIPC handler.["node", "<abs-path>"]command is written toopencode.jsoninstead of["npx", "-y", "chrome-devtools-mcp@latest"].prepare-sidecar.mjs. The shim script itself is updated to try the bundled package first and fall back tonpm execonly if unavailable.Why
Not every user has
npxavailable. Since Electron already ships a full Node.js runtime, we can resolve and run the bundled package directly — zero external tooling required.Test plan
apps/app/tests/chrome-devtools-mcp-resolution.test.ts— testsbuildChromeDevtoolsCommandwith resolved base,isChromeDevtoolsMcp,usesChromeDevtoolsAutoConnect, and verifies the installed package bin is resolvable.apps/desktop/scripts/chrome-devtools-mcp-shim.test.ts— verifies the shim resolution logic, bin shebang, package.jsonbinfield, and pinned version.bun test apps/app/tests/— 0 failures)..rsauto-injection and Tauri sidecar config remain as-is for backwards compatibility).Files changed
apps/desktop/package.jsonchrome-devtools-mcp@0.17.0dependencyapps/desktop/electron/main.mjsresolveChromeDevtoolsMcpBinIPC +createRequireimportapps/app/src/app/mcp.tsresolveChromeDevtoolsMcpCommand()async resolverapps/app/src/react-app/domains/connections/store.tsapps/desktop/scripts/chrome-devtools-mcp-shim.tsapps/desktop/scripts/prepare-sidecar.mjspnpm-lock.yaml