Skip to content

Commit 7febfb0

Browse files
authored
Merge pull request #377 from editor-code-assistant/fix/mcp-windows-browser-open
Fix MCP OAuth browser not opening on Windows
2 parents b31e684 + 75e787d commit 7febfb0

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix MCP OAuth browser not opening on Windows by using `cmd /c start` instead of `java.awt.Desktop`, which is unavailable in the native image.
6+
57
## 0.117.1
68

79
- Fix remote server on Windows stealing TLS traffic from Tailscale/WireGuard when using the same port, by binding to specific interfaces instead of `0.0.0.0` when tunnel adapters are detected.

src/eca/features/tools/mcp.clj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@
354354
(do (try (pp/stop-client-transport! transport false) (catch Exception _))
355355
(if (< attempt max-init-retries)
356356
(do (logger/warn logger-tag
357-
(format "MCP server '%s' transport error during initialization (attempt %d/%d), retrying"
358-
name attempt max-init-retries))
357+
(format "MCP server '%s' transport error during initialization (attempt %d/%d), retrying"
358+
name attempt max-init-retries))
359359
(try-refresh-token! name db* url metrics server-config)
360360
:retry)
361361
(do (logger/error logger-tag (format "MCP server '%s' transport error during initialization" name))
@@ -441,6 +441,15 @@
441441
(logger/info logger-tag (format "Starting MCP server %s from manual request despite :disabled=true" name)))
442442
(initialize-server! name db* config metrics on-server-updated)))
443443

444+
(defn ^:private open-browser! [^String url]
445+
(try
446+
(if shared/windows-os?
447+
(-> (ProcessBuilder. ["cmd" "/c" "start" "" url])
448+
(.start))
449+
(browse/browse-url url))
450+
(catch Exception e
451+
(logger/error logger-tag (str "Failed to open browser: " (.getMessage e))))))
452+
444453
(defn connect-server!
445454
"Initiate OAuth authorization for an MCP server that requires auth.
446455
Starts the local OAuth callback server and returns the authorization URL."
@@ -468,7 +477,7 @@
468477
(logger/error logger-tag error)
469478
(swap! db* assoc-in [:mcp-clients name :status] :failed)
470479
(on-server-updated (->server name server-config :failed @db*)))})
471-
(browse/browse-url authorization-endpoint)))))
480+
(open-browser! authorization-endpoint)))))
472481

473482
(defn ^:private restart-server!
474483
"Stop the server if running, then spawn a daemon thread to re-initialize it."

0 commit comments

Comments
 (0)