Skip to content

[MCP OAuth][Windows] Codex CLI 0.156.1 fails reading 401 metadata challenge #47756

Open

Description

@yuya-fukunaga

What version of Codex CLI is running?

codex-cli 0.156.1 (Windows x64, standalone installation). The immediately previous official Windows release, 0.155.0, works with the same MCP server and configuration.

What subscription do you have?

Not specified. The failure occurs during MCP OAuth metadata discovery, before any model request.

Which model were you using?

Not applicable; this is reproducible with codex mcp login.

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64 (Windows 11 Professional), native Windows CLI.

What terminal emulator and version are you using (if applicable)?

Windows Terminal, PowerShell.

Codex doctor report

codex doctor --json reports the standalone installation and MCP configuration as locally consistent, with no proxy environment variables configured. The full report is omitted because it contains local filesystem paths and account-state details.

What issue are you seeing?

On native Windows, codex mcp login <server> fails before opening the OAuth authorization page:

Error: Metadata error: OAuth metadata discovery failed for https://<mcp-host>/mcp
  Caused by: HTTP request failed: error decoding response body

The MCP server is configured as Streamable HTTP. Its protected-resource metadata endpoint and the Entra OIDC discovery endpoint both return HTTP 200 with valid JSON when fetched using curl.exe. The same failure occurs when invoking codex mcp login directly, so it is not caused by the PowerShell installer wrapper. The saved MCP URL and requested scope are correct, and no proxy is configured.

What steps can reproduce the bug?

  1. On native Windows x64, install Codex CLI 0.156.1 and configure a Streamable HTTP MCP server at https://<mcp-host>/mcp that responds to unauthenticated requests with HTTP 401 and a valid WWW-Authenticate: Bearer resource_metadata="https://<mcp-host>/.well-known/oauth-protected-resource/mcp" challenge.
  2. Confirm that the advertised protected-resource metadata URL returns a valid JSON document pointing to a valid OAuth/OIDC authorization server metadata document.
  3. Run codex mcp login <server>.
  4. Observe the metadata discovery error above.

This was also reproduced with a local loopback mock server. Codex 0.156.1 on Windows sent the initial GET to /mcp, then failed with error decoding response body without requesting the advertised /.well-known/oauth-protected-resource/... document. The same failure occurred when the 401 body was empty and when the response included Connection: close.

Cross-checks:

  • Codex CLI 0.156.1 on Ubuntu under WSL, with the same MCP URL, scopes, and client ID, completed OAuth login successfully.
  • The official Codex CLI 0.155.0 Windows executable, with the same Windows MCP configuration and server, completed OAuth login and loaded all 5 MCP tools.
  • Windows Codex 0.156.1 fails both from the PowerShell installer and from a direct codex mcp login invocation.
  • The previously reported generic metadata-discovery issue #5953 is closed and does not describe this Windows 0.156.1 versus 0.155.0/WSL regression.

What is the expected behavior?

Codex should read the 401 challenge, fetch the advertised protected-resource metadata and authorization-server metadata, and continue the OAuth login flow, as it does on WSL 0.156.1 and native Windows 0.155.0.

Additional information

The evidence points to a Windows-specific failure while reading the initial 401 response body during OAuth metadata discovery. The issue is reproducible without contacting the production MCP server, so it does not appear to depend on the server's metadata contents, Entra, or the installer.

Activity

  1. added
    bug
    CLI
    windows-os
    mcp
    auth
    on Sep 24, 2026
  2. HJN-Reiten commented on Oct 28, 2026

    @HJN-Reiten

    Additional Windows reproduction, observed on 2026-10-28.

    I submitted the full diagnostic report through ChatGPT feedback.
    Feedback ID: f3320971-b8e0-49c3-8972-c7ac655ee465

    Environment:

    • Windows NT 10.0.26300.0, x64
    • native local Windows Codex session
    • codex-cli 0.165.0-alpha.1.2
    • MCP transport: streamable_http
    • MCP endpoint: https://www.capcut.com/api/external_mcp
    • CapCut plugin 0.2.6

    Reproduction:

    codex.exe mcp login capcut_creation
    

    fails before any OAuth browser page opens:

    Error: Metadata error: OAuth metadata discovery failed for
    https://www.capcut.com/api/external_mcp
      Caused by: HTTP request failed: error decoding response body
    

    Exit code: 1.

    The same failure had previously occurred with codex-cli 0.164.0-alpha.11.1. After an official ChatGPT Windows app update, the bundled/local CLI changed to 0.165.0-alpha.1.2, but the OAuth discovery error remained reproducible.

    Important control result: the complete OAuth discovery chain is independently readable with native Windows curl.exe using Schannel:

    • MCP endpoint returns the expected 401 with WWW-Authenticate and resource_metadata.
    • Protected Resource Metadata returns HTTP 200 and valid JSON.
    • OAuth Authorization Server Metadata returns HTTP 200 and valid JSON.
    • The advertised issuer and authorization server match.
    • PKCE S256, authorization endpoint, token endpoint and registration endpoint are present.

    There are no HTTP/HTTPS proxy environment variables in the tested process and WinHTTP reports direct access.

    Norton HTTPS inspection is active on this machine and re-signs TLS traffic. However, the complete CapCut OAuth metadata responses are successfully transferred and parsed by Windows curl.exe, so HTTPS inspection is confirmed but has not been demonstrated to corrupt these responses.

    Local Codex logs contain:

    failed to determine auth status for MCP server `capcut_creation`:
    Metadata error: OAuth metadata discovery failed for
    https://www.capcut.com/api/external_mcp
      Caused by: HTTP request failed: error decoding response body
    

    but do not expose which individual metadata request fails internally, its HTTP status, or the deeper reqwest/hyper decoding cause.

    The failure was also reproduced from a newly created, confirmed local Windows Codex session after the latest ChatGPT app update, so it is not limited to an older Work chat or cloud/Linux execution environment.

    Could the maintainers please correlate this with feedback ID f3320971-b8e0-49c3-8972-c7ac655ee465 and advise whether this is the same Windows MCP/OAuth response-decoding path as reported in #47756?

    No credentials, OAuth tokens, or private media were involved.

  3. 2440-pon commented on Nov 12, 2026

    @2440-pon

    I reproduced this on Windows with Codex CLI 0.167.0-alpha.4.1 and Home Assistant MCP. Both OAuth discovery and bearer-token MCP initialization fail with error decoding response body. On the same machine, PowerShell successfully initializes the same MCP endpoint with the same token (HTTP 200) and calls a read-only tool.
    Feedback thread ID: 01a1d1d9-aa02-73c3-8df3-ede1e17f23a2 (no logs uploaded).

  4. SholaOgunde commented on Nov 16, 2026

    @SholaOgunde

    Potential Workaround

    I had a similar issue using Figma MCP with Codex Desktop and ChatGPT helped me troubleshoot it.

    Workaround for Norton 360 Premium

    Open Norton 360.

    1. Select Security.
    2. Navigate to Advanced Security → Web → Safe Web.
    3. Open the Settings tab.
    4. Expand Safe Web dropdown
    5. Look for HTTPS scanning.

    If HTTPS scanning is set,

    1. Open the Exclusions tab.
    2. Add these sites
    • mcp.figma.com : for MCP communication
    • api.figma.com : for OAuth metadata and token operations
    • www.figma.com : for interactive authorisation

    Adding one server is not enough. All related endpoints need to be added. I got ChatGPT to help me discover which endpoints were used as part of the process - using the following standard commands

  5. Mateus2431 commented on Nov 16, 2026

    @Mateus2431

    Additional reproduction on Windows with VS Code Codex extension 26.51111.21308 (codex-cli 0.169.0-alpha.11.1) and the official Trello MCP endpoint https://mcp.trello.com/v1. Running codex mcp login trello fails before browser authorization:

    Metadata error: OAuth metadata discovery failed for https://mcp.trello.com/v1
    Caused by: HTTP request failed: error decoding response body

    The MCP endpoint returns the expected HTTP 401 with WWW-Authenticate pointing to its protected-resource metadata. Windows curl.exe reads that metadata as HTTP 200 valid JSON, and independently reads the advertised Atlassian authorization-server metadata as HTTP 200 valid JSON. Both were tested without disabling TLS verification. Reinstalling the same current pre-release extension did not change the error. No Trello cards were written. This looks similar to the Windows OAuth response-decoding path reported here; the exact cause on this machine has not been established. Please advise on a targeted diagnostic or supported workaround.

  6. MysticalFive33 commented on Nov 20, 2026

    @MysticalFive33

    Additional reproduction: CapCut 0.3.1 on current Windows Codex Desktop

    Observed on 2026-11-19 at approximately 19:00 (America/Mexico_City).

    Environment:

    • Windows 11 Home 25H2, build 26200.9974, x64
    • Codex Desktop Appx package: 26.1111.9664.0
    • Component build reported by support: 26.1111.71704
    • Bundled codex-cli 0.169.1
    • Official CapCut@CapCut 0.3.1, installed, enabled, and not modified or reinstalled
    • MCP server: capcut_creation
    • MCP endpoint: https://www.capcut.com/api/external_mcp

    The official plugin runbook requires its bundled capcut-login.mjs helper. The helper exits before any OAuth authorization page or URL is generated:

    OAuth metadata discovery failed for
    https://www.capcut.com/api/external_mcp
    Caused by: HTTP request failed: error decoding response body
    

    The connection checker reports status=unknown, reason=connection_not_confirmed; protected tools remain unavailable.

    Checks completed:

    • Windows user proxy, PAC, and automatic detection are disabled.
    • HTTP_PROXY, HTTPS_PROXY, and CODEX_CA_CERTIFICATE are not defined.
    • The same failure was reproduced on a phone hotspot without VPN.
    • /.well-known/oauth-protected-resource/api/external_mcp returns HTTP 200, gzip-encoded valid JSON.
    • /.well-known/oauth-authorization-server/api/external_mcp/oauth returns HTTP 200, gzip-encoded valid JSON; the issuer matches and the authorization, token, and registration endpoints are present.

    This failure occurs before client registration and before an authorization URL is produced, so it is earlier than the duplicate-resource / unknown client flow discussed in #58808.

    Expected behavior: Codex should complete metadata discovery, open the CapCut authorization page, and make the protected MCP tools available.

    Feedback/session ID for correlation: 01a1f65e-b2fc-78f1-8f4f-9ff145a3f8ab.

    Could maintainers correlate this feedback session and expose the nested HTTP/decompression cause currently collapsed into error decoding response body? No credentials, OAuth tokens, callback URLs, or private media are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIauthbugmcpwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions