You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6473d5e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(desktop): in-process browser MCP servers — no sidecars, no npx (anomalyco#1676)
* feat(desktop): in-process browser MCP servers using chrome-devtools-mcp as library
Import chrome-devtools-mcp tools, McpContext, and McpResponse as library
modules (never import main.js — it has CLI side effects). Two MCP servers
run inside the Electron main process:
openwork-browser — controls the embedded WebContentsView via Electron's
own CDP endpoint. Auto-opens the browser panel when a tool is called.
chrome — connects to the user's external Chrome (port 9222/9229) for
controlling their real browser with cookies, extensions, etc.
Both are exposed as HTTP MCP endpoints (StreamableHTTPServerTransport)
and auto-injected into opencode.json as remote MCP servers. Legacy local
chrome-devtools and control-chrome entries are cleaned up.
No sidecars, no npx, no absolute paths. The chrome-devtools-mcp npm
package ships as a dependency and its tools run in-process.
Architecture:
Electron main process
├── browser-mcp.mjs (imports chrome-devtools-mcp pieces)
│ ├── McpServer + tools from chrome-devtools-mcp
│ ├── puppeteer.connect(browserURL) for CDP
│ └── StreamableHTTPServerTransport on localhost
├── WebContentsView (built-in browser, demand-driven)
└── opencode.json: { mcp: { openwork-browser: {type:remote}, chrome: {type:remote} } }
Verified:
- Both servers start and respond to /health
- opencode.jsonc gets correct remote MCP entries
- App detects config change and offers reload
- All 17 existing tests pass
* fix(desktop): target WebContentsView only for built-in browser MCP, not main renderer
The built-in browser MCP server was controlling the main OpenWork
renderer (localhost:5173) instead of the embedded WebContentsView
because puppeteer.connect() picked whichever CDP target came first.
Fixes:
- Add BUILTIN_TARGET_FILTER that excludes file://, localhost, 127.0.0.1
and about:blank — only real websites in the WebContentsView match
- Separate connectBuiltinBrowser vs connectExternalBrowser functions
- Make onBuiltinToolCall async — it now creates the WebContentsView and
waits for the default URL to load BEFORE the tool handler connects
via puppeteer, ensuring the target exists
- Force reconnect on each built-in tool call so puppeteer always sees
the latest WebContentsView target (not a stale connection from before
the view was created)
* fix(desktop): open browser panel on every built-in tool call, add show/hide tools
- Use browserViewVisible flag (not DOM children check) to reliably
detect whether the panel needs opening
- Every openwork-browser tool call ensures the panel is visible before
puppeteer connects — the agent can't interact with an invisible panel
- Add show_browser tool: explicitly open the panel (also auto-called)
- Add hide_browser tool: close the panel when the task is done
- onHideBrowser callback in main.mjs sends panel-closed event to renderer
- External chrome MCP is untouched — it never touches the panel
* feat(agent): update openwork.md with browser tool instructions
The default agent now knows about both browser MCP servers and when to
use each one:
- openwork-browser (built-in): default for general browsing, panel
auto-opens, call hide_browser when done
- chrome (external): use when the user needs real cookies/extensions
Updated in both the server workspace-init.ts (Electron path) and the
Tauri files.rs. Removed the old 'ask user to add Control Chrome'
instruction since browser tools are now built-in and always available.
* fix(desktop): sync browser panel React UI with main process open/close events
When the agent calls a built-in browser tool, the main process opens
the WebContentsView but the React BrowserPanel component wasn't being
rendered — so no toolbar (URL bar, back/forward, close button).
Fix: the main process sends panel-opened/panel-closed IPC events, the
preload exposes onPanelOpened/onPanelClosed listeners, and session-page
subscribes to them to set browserPanelOpen state. Now both paths
(user clicks Browser button, or agent calls a tool) produce the same
UI with the full toolbar.
* fix(desktop): fix MCP HTTP server session handling — one server per session
The previous implementation called mcpServer.connect(transport) for
every new session on a single McpServer instance. McpServer only
supports one transport at a time, so subsequent sessions would hang.
Fix: startMcpHttpServer now takes a factory function instead of a
server instance. Each new MCP session (no mcp-session-id header)
creates a fresh server+transport pair. Existing sessions reuse their
transport via the session ID header.
This matches how StreamableHTTPServerTransport is designed to work
and should fix OpenCode failing to connect to the remote MCP servers.
* chore(desktop): remove legacy Control Chrome connector UI and sidecar remnants
Remove the old user-facing Control Chrome connector flow now that browser
automation is built into OpenWork:
- remove Chrome quick-connect entry and npx command constants
- remove ControlChromeSetupModal and settings UI buttons
- remove chrome-devtools local command resolution helpers from mcp.ts/store.ts
- remove obsolete chrome-devtools-mcp shim script and sidecar prep metadata
- remove Control Chrome / quick-connect Chrome i18n keys
- keep only an internal migration cleanup that deletes legacy control-chrome
config entries from existing workspaces
Verified no user-facing Control Chrome references remain in app/server/electron/scripts.
* fix(desktop): preserve built-in browser MCP context across snapshot and input tools
The built-in browser MCP was reconnecting Puppeteer on every tool call.
chrome-devtools-mcp stores the latest accessibility snapshot on its
McpContext, so reconnecting after take_snapshot created a fresh context
and follow-up fill/click calls failed with 'No snapshot found'.
Now the built-in browser connection is reused while connected. The
WebContentsView is still opened before the first tool call, so the
initial connection targets the panel, but subsequent tools preserve
snapshot state and UID mappings.
* fix(desktop): guide external Chrome connection setup
"mcp.control_chrome_browser_step_two": "Activa la depuració remota.",
590
-
"mcp.control_chrome_browser_step_three": "Permet connexions de depuració entrants quan Chrome ho demani.",
591
-
"mcp.control_chrome_browser_title": "1. Activa l'accés a Chrome",
592
-
"mcp.control_chrome_connect": "Afegeix Control Chrome",
593
-
"mcp.control_chrome_docs": "Guia oficial MCP",
594
-
"mcp.control_chrome_edit": "Edita la configuració",
595
-
"mcp.control_chrome_profile_hint": "Control Chrome normalment obre un perfil Chrome independent. Activeu-ho si voleu que OpenWork reutilitzi la finestra Chrome que ja teniu oberta.",
596
-
"mcp.control_chrome_profile_title": "2. Tria quin Chrome vols fer servir",
597
-
"mcp.control_chrome_save": "Desa la configuració",
598
-
"mcp.control_chrome_setup_subtitle": "Activa l'accés a Chrome i tria si OpenWork ha de fer servir un perfil net propi o enganxar-se al Chrome que ja tens obert.",
599
-
"mcp.control_chrome_setup_title": "Configura Control Chrome",
600
-
"mcp.control_chrome_toggle_hint": "Quan això està activat, OpenWork afegeix --autoConnect de manera que el MCP s'adjunta a una instància Chrome que ja heu iniciat.",
601
-
"mcp.control_chrome_toggle_label": "Utilitza el meu perfil Chrome existent",
602
-
"mcp.control_chrome_toggle_off": "OpenWork llançarà un perfil Chrome independent només per a l'automatització.",
603
-
"mcp.control_chrome_toggle_on": "OpenWork reutilitzarà les vostres pestanyes, galetes i inicis de sessió actuals.",
604
587
"mcp.custom_app_cta_hint": "Connecta el teu servidor MCP, una eina interna o una app allotjada.",
605
588
"mcp.desktop_required": "Les aplicacions requereixen el app d'escriptori.",
606
589
"mcp.docs_link": "Més informació",
@@ -633,8 +616,6 @@ export default {
633
616
"mcp.opening_label": "S'està obrint...",
634
617
"mcp.pick_workspace_error": "Tria primer una carpeta de workspace.",
635
618
"mcp.pick_workspace_first": "Tria primer una carpeta de workspace.",
636
-
"mcp.quick_connect_chrome_desc": "Controla pestanyes de Chrome amb automatització del navegador.",
"chrome_setup.info_what_this_enables": "When connected, OpenWork can navigate tabs, fill forms, and read pages in your real Chrome — including sites where you're signed in. You can disconnect at any time by disabling remote debugging in Chrome.",
"chrome_setup.step_one_hint": "Chrome 144+ lets you enable this without restarting. Your existing tabs, cookies, and sign-ins stay intact.",
93
+
"chrome_setup.step_one_open_inspect": "In Chrome, go to",
94
+
"chrome_setup.step_one_title": "Turn on Chrome remote debugging",
95
+
"chrome_setup.step_two_hint": "After enabling remote debugging, click the button below to verify OpenWork can reach Chrome.",
96
+
"chrome_setup.step_two_title": "Test the connection",
97
+
"chrome_setup.subtitle": "Let OpenWork control your real Chrome browser — your tabs, cookies, and sign-ins — so it can work with sites where you're already logged in.",
"mcp.control_chrome_browser_step_three": "Allow incoming debugging connections when Chrome asks.",
602
-
"mcp.control_chrome_browser_title": "1. Turn on Chrome access",
603
-
"mcp.control_chrome_connect": "Add Control Chrome",
604
-
"mcp.control_chrome_docs": "Official MCP guide",
605
-
"mcp.control_chrome_edit": "Edit settings",
606
-
"mcp.control_chrome_profile_hint": "Control Chrome normally opens a separate Chrome profile. Turn this on if you want OpenWork to reuse the Chrome window you already have open.",
607
-
"mcp.control_chrome_profile_title": "2. Choose which Chrome to use",
608
-
"mcp.control_chrome_save": "Save settings",
609
-
"mcp.control_chrome_setup_subtitle": "Turn on Chrome access, then choose whether OpenWork should use its own clean profile or attach to the Chrome you already use.",
610
-
"mcp.control_chrome_setup_title": "Set up Control Chrome",
611
-
"mcp.control_chrome_toggle_hint": "When this is on, OpenWork adds --autoConnect so the MCP attaches to a Chrome instance you already started.",
612
-
"mcp.control_chrome_toggle_label": "Use my existing Chrome profile",
613
-
"mcp.control_chrome_toggle_off": "OpenWork will launch a separate Chrome profile just for automation.",
614
-
"mcp.control_chrome_toggle_on": "OpenWork will reuse your current tabs, cookies, and sign-ins.",
615
618
"mcp.custom_app_cta_hint": "Connect your own MCP server, internal tool, or hosted app.",
616
619
"mcp.desktop_required": "Apps require the desktop app.",
617
620
"mcp.docs_link": "Learn more",
@@ -644,8 +647,6 @@ export default {
644
647
"mcp.opening_label": "Opening...",
645
648
"mcp.pick_workspace_error": "Choose a workspace folder first.",
646
649
"mcp.pick_workspace_first": "Choose a workspace folder first.",
647
-
"mcp.quick_connect_chrome_desc": "Drive Chrome tabs with browser automation.",
"mcp.control_chrome_profile_hint": "Control Chrome suele abrir un perfil de Chrome aparte. Activa esta opción si quieres que OpenWork reutilice la ventana de Chrome que ya tienes abierta.",
"mcp.control_chrome_setup_subtitle": "Activa el acceso a Chrome y luego elige si OpenWork debe usar un perfil limpio propio o conectarse al Chrome que ya usas.",
599
-
"mcp.control_chrome_setup_title": "Configurar Control Chrome",
600
-
"mcp.control_chrome_toggle_hint": "Cuando esto está activado, OpenWork añade --autoConnect para que MCP se conecte a una instancia de Chrome que ya has abierto.",
601
-
"mcp.control_chrome_toggle_label": "Usar mi perfil Chrome existente",
602
-
"mcp.control_chrome_toggle_off": "OpenWork abrirá un perfil de Chrome aparte solo para la automatización.",
603
-
"mcp.control_chrome_toggle_on": "OpenWork reutilizará tus pestañas, cookies e inicios de sesión actuales.",
604
587
"mcp.custom_app_cta_hint": "Conecta tu propio servidor MCP, herramienta interna o app alojada.",
605
588
"mcp.desktop_required": "Las apps requieren la app de escritorio.",
606
589
"mcp.docs_link": "Más información",
@@ -633,8 +616,6 @@ export default {
633
616
"mcp.opening_label": "Abriendo...",
634
617
"mcp.pick_workspace_error": "Elige primero una carpeta del espacio de trabajo.",
635
618
"mcp.pick_workspace_first": "Elige primero una carpeta del espacio de trabajo.",
636
-
"mcp.quick_connect_chrome_desc": "Controla pestañas de Chrome con automatización del navegador.",
"mcp.control_chrome_browser_step_two": "Activez le débogage à distance.",
590
-
"mcp.control_chrome_browser_step_three": "Autorisez les connexions de débogage entrantes lorsque Chrome le demande.",
591
-
"mcp.control_chrome_browser_title": "1. Activer l'accès à Chrome",
592
-
"mcp.control_chrome_connect": "Ajouter Control Chrome",
593
-
"mcp.control_chrome_docs": "Guide MCP officiel",
594
-
"mcp.control_chrome_edit": "Modifier les paramètres",
595
-
"mcp.control_chrome_profile_hint": "Control Chrome ouvre normalement un profil Chrome séparé. Activez ceci si vous voulez qu'OpenWork réutilise la fenêtre Chrome déjà ouverte.",
596
-
"mcp.control_chrome_profile_title": "2. Choisir quel Chrome utiliser",
597
-
"mcp.control_chrome_save": "Enregistrer les paramètres",
598
-
"mcp.control_chrome_setup_subtitle": "Activez l'accès à Chrome, puis choisissez si OpenWork doit utiliser son propre profil propre ou se rattacher au Chrome que vous utilisez déjà.",
599
-
"mcp.control_chrome_setup_title": "Configurer Control Chrome",
600
-
"mcp.control_chrome_toggle_hint": "Lorsque cette option est activée, OpenWork ajoute --autoConnect pour que le MCP se rattache à une instance Chrome que vous avez déjà démarrée.",
0 commit comments