Repository navigation
fix(mcp): open the login and consent pages in the browser on Windows - #85
Merged
Merged
Conversation
Both local pages were launched with exec(`start "<url>"`). On Windows, cmd's start reads its first quoted argument as a window title, so it opened an empty console titled with the URL and launched no browser; the tool call then waited out the login timeout with nothing in front of the user. Both pages now go through one launcher, browser-launch.ts, that runs no shell and hands the URL to the opener as its own argument: open on macOS, xdg-open on Linux, and rundll32 url.dll,FileProtocolHandler on Windows. The consent page also now reports a failed launch on stderr with its URL, as the login page already did, instead of ignoring it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 6 tasks
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.
Problem
Reported against
@formio/mcp0.13.0 on Windows 11 / Node 22 / Claude Code: when a tool call needs portal login, an empty console window opens with the login URL as its title, no browser opens, and the call waits out the login timeout with no page in front of the user.Both local pages — the portal login (
auth.ts) and the revisions consent page (revisions/browser-prompts.ts) — were opened with:execruns that throughcmd.exe /c, andstartreads its first quoted argument as the window title, sostart "http://127.0.0.1:53555/"opens a titled console and launches nothing.Fix
A new
browser-launch.tsthat both pages use:browserLaunchCommand(url, platform)— pure; returns the program and its argument list:open <url>on macOS,xdg-open <url>on Linux,rundll32.exe url.dll,FileProtocolHandler <url>on Windows (the same approach as GitHub'scli/browser).openInBrowser(url, onError)— runs it withexecFile(no shell,windowsHide: true), so the URL is one argument on every platform and nothing in it is parsed by cmd or sh.Windows avoids
startentirely: it is a cmd built-in, so it needs a shell, and its title slot is the bug.The consent page previously ignored a failed launch. It now writes the failure and its URL to stderr, as the login page already did. README's "Headless environments" line, which named
start, is updated.Tests
browser-launch.test.ts— command per platform, Windows never usesstart,execFilecalled with the URL as its own argument, failure reported / success not reported.browser-prompts-launch.test.ts— consent page launches through the shell-free launcher and names its URL on stderr when the launch fails.execFileinstead ofexec.pnpm test,pnpm lint,pnpm formatandpnpm check:releasespass. Not yet exercised on a real Windows machine.Known limits / not in this PR
rundll32exits 0 even when no handler is registered, so on Windows a failed launch usually produces no "Could not open a browser" line. The login URL is still always on stderr and in the timeout error.🤖 Generated with Claude Code