Repository navigation
Description
Describe the bug
This issue was split out of #4017 at a maintainer's request. It isn't #5250 either: there's no OS broker here, and the CLI logs Entra broker not eligible; using the browser OAuth flow {"broker_available":false}.
I retested on CLI 1.0.114 on WSL2 Ubuntu 24.04 with an Entra-protected remote HTTP MCP server (the Azure DevOps remote MCP, https://mcp.dev.azure.com/<org>) and no stored token. The browser flow itself now works. When a browser opens, Entra SSO completes, the loopback callback reaches the CLI, and the CLI logs MCP OAuth tokens saved. The token falls back to file storage under ~/.copilot/mcp-oauth-config/ because there's no Secret Service, and a restart reuses it. Device code (Ctrl+G) now shows a code. Each flow uses a per-flow random loopback port, so the "fixed callback port" I described in #4017 doesn't apply on 1.0.114.
Two problems remain, plus one on the app side.
1. When xdg-open is missing, sign-in stalls with no URL and no visible error
A stock WSL Ubuntu install has no xdg-utils, though wslview is installed. The launch fails, and the failure is logged only at DEBUG:
[DEBUG] [rust:mcp_client::oauth_flow] Entra broker not eligible; using the browser OAuth flow {"server_url":"https://mcp.dev.azure.com/<org>","broker_available":false,"force_device_code":false}
[ERROR] Opening browser for ado-direct authentication...
[DEBUG] [rust:mcp_client::oauth_flow] failed to open OAuth browser {"error":"Spawn { command: \"xdg-open\", source: Os { code: 13, kind: PermissionDenied, message: \"Permission denied\" } }"}
[ERROR] Requesting access token for ado-direct...
The PermissionDenied error is misleading because no xdg-open exists on PATH. I suspect execvp returns EACCES from a Windows-interop PATH entry. The CLI doesn't print the authorize URL or fall back to $BROWSER or wslview. The user sees only:
! MCP server 'ado-direct' is taking longer than expected to connect.
! Gave up waiting for MCP server to finish starting: ado-direct. Startup continued without it; it may still connect.
After that, the CLI contacts login.microsoftonline.com about every 6 s indefinitely, and the server stays pending.
2. /mcp → server → Authenticate shows a URL whose callback is rejected
While the startup flow is pending, choosing Authenticate shows:
A browser authorization is already in progress for this server. Open the URL below to complete it.
If your browser didn't open, copy this URL manually: https://login.microsoftonline.com/<tenant>/oauth2/v2.0/authorize?...
The displayed URL is identical to the startup flow's URL, including state and nonce. But the action also starts a new flow: session.mcp.oauth.prepareFlow runs again. When I complete the displayed URL in the browser, Entra and the vscode.dev/redirect hop succeed, and the loopback callback reaches the CLI. The CLI then rejects it:
- With a working browser opener: the callback page shows "Authorization Failed — State mismatch - possible CSRF attack".
- After the
xdg-openfailure in (1): the callback returns HTTP 404 Not Found. Replaying the same callback URL from inside WSL withcurlalso returns 404, which rules out WSL localhost forwarding. Nothing is logged.
If I skip Authenticate and open the startup URL directly, sign-in succeeds, even about 70 s after startup "gave up waiting". So the only URL the UI ever shows is one that can't complete. Without a working xdg-open, the user has no way to sign in from the UI. That matches my original #4017 symptom: the browser reports success, but no token is stored.
3. App sessions on a WSL host have no sign-in path
In GitHub Copilot app 1.4.2 (Windows) with sessions on a WSL host, the host was still running bundled CLI 1.0.104-0 (copilotd 1.0.5) and didn't update to 1.0.114. A new session lists the server's tool names, which may come from the tool snapshot cache. Every call fails:
MCP server 'ado-direct': MCP server "ado-direct" requires authentication. Sign in through your MCP client's authentication settings.
No browser opens on Windows, and I found no sign-in action for the server in the app. The Windows app log shows only session/mcpServerStateChanged actions with translated_event_count=0 and no auth-related action. If this is already fixed in a newer host, please say which copilotd or CLI version to wait for.
Expected behavior
- If launching the browser fails, show the authorize URL in the session immediately, log the failure at WARNING, and fall back to
$BROWSERorwslviewon WSL. - When Authenticate runs while a flow is pending, either keep the pending flow's
state/noncevalid or display the new flow's URL. Never show a URL the callback will reject. - App sessions on Linux/WSL remote hosts should surface MCP OAuth-required in the app with a Sign in action that completes the flow. Opening the Windows browser works: WSL localhost forwarding delivers the callback to the host process.
Affected version
- GitHub Copilot CLI 1.0.114 (linux-x64 release tarball,
--no-auto-update) - GitHub Copilot app 1.4.2 (Windows), with its WSL host serving sessions using bundled CLI 1.0.104-0
Environment
- Windows 11 + WSL2, Ubuntu 24.04.5, kernel 6.18 (microsoft-standard-WSL2)
- No
xdg-open(xdg-utilsnot installed);wslviewpresent;BROWSERunset - No Secret Service (
org.freedesktop.secrets), so MCP tokens fall back to~/.copilot/mcp-oauth-config/ - Server: Azure DevOps remote MCP,
type: http, nooauthClientId
Steps to reproduce
- On WSL Ubuntu without
xdg-utils, with no stored MCP token, run:
copilot --log-level debug --additional-mcp-config '{"mcpServers":{"ado-direct":{"type":"http","url":"https://mcp.dev.azure.com/<org>","tools":["*"]}}}' - Observe "taking longer than expected" and no URL. The log shows the
xdg-openspawn failure. - Open
/mcp→ado-direct→ Authenticate. Copy the displayed URL into a Windows browser and complete sign-in. - The callback returns 404 (or "State mismatch" if an opener exists), and the server stays unauthenticated.
- Control: put an
xdg-openshim onPATHthat hands the URL to the Windows browser, and restart without clicking Authenticate. Sign-in completes and the server connects.
Workaround: install xdg-utils, or put an xdg-open shim on PATH that calls wslview, and don't click Authenticate while the startup flow is pending. That fixes the standalone CLI only. For app sessions on a WSL host, I still use a local stdio proxy that adds a bearer token from az account get-access-token.
(These details we created using GHCP attempting to repro another bug/fix.)
Activity
hstaudacher commentedon Nov 19, 2026
Thanks for the thorough split from #4017. Confirmed as valid: on WSL without
xdg-openthe browser launch fails silently and no URL is shown, and/mcpAuthenticate shows the pending flow's URL while starting a new flow, which causes the state mismatch. #5350 has been closed as a duplicate of this. Moved to the backlog.