Skip to content

MCP OAuth login fails for Kapa-hosted Strapi docs server unless authorize URL includes resource parameter #11292

Closed

Description

@Chudroy

What version of Codex CLI is running?

codex-cli 0.98.0

What subscription do you have?

Plus (ChatGPT account)

Which model were you using?

gpt-5.3-codex

What platform is your computer?

Linux 6.8.0-40-generic x86_64 x86_64

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

VS Code integrated terminal (TERM=dumb)

What issue are you seeing?

codex mcp login fails for Strapi’s Kapa-hosted MCP server with OAuth callback error:

http://127.0.0.1:<port>/callback?error=server_error&error_description=An+unexpected+error+occurred&state=...

I can reproduce this consistently with:

  • MCP URL: https://strapi-docs.mcp.kapa.ai
  • Scope: openid
  • Callback port fixed (mcp_oauth_callback_port = 4317) or ephemeral port

The server’s protected resource metadata is:

https://strapi-docs.mcp.kapa.ai/.well-known/oauth-protected-resource

which returns:

  • "resource": "https://strapi-docs.mcp.kapa.ai/"
  • "authorization_servers": ["https://mcp.kapa.ai/auth/google"]
  • "scopes_supported": ["openid"]

From codex mcp login, the generated authorization URL includes scope=openid but does not include a resource query param.
When resource is missing, auth redirects back with error=server_error.

If I manually add this to the same authorize URL:

&resource=https%3A%2F%2Fstrapi-docs.mcp.kapa.ai%2F

the flow proceeds to consent instead of failing.

What steps can reproduce the bug?

  1. Put this in ~/.codex/config.toml:
    mcp_oauth_callback_port = 4317
    
    [mcp_servers.strapi_docs]
    url = "https://strapi-docs.mcp.kapa.ai"
    enabled = true

Run:

bash

codex mcp login strapi_docs --scopes openid
Open the printed URL.
Observe callback error:
error=server_error&error_description=An+unexpected+error+occurred.
Optional validation:

Use the same printed authorize URL.
Append:
&resource=https%3A%2F%2Fstrapi-docs.mcp.kapa.ai%2F
Open modified URL.
Observe it redirects to consent flow instead of immediate callback error.


### What is the expected behavior?

codex mcp login should successfully complete OAuth for this MCP server without manual URL edits.

Specifically, when protected resource metadata includes a resource value, Codex should include that resource in the authorize request (or otherwise negotiate correctly) so the provider does not return server_error.

Additional information
This may be related to MCP OAuth protected-resource handling gaps (possibly related to #8889).



### Additional information

_No response_

Activity

  1. added
    bug
    on Feb 10, 2026
  2. added
    CLI
    mcp
    auth
    on Feb 10, 2026
  3. removed
    CLI
    on Feb 10, 2026
  4. etraut-openai commented on Feb 10, 2026

    @etraut-openai
    Contributor

    Thanks for the bug report.

    Since this is specific to a single MCP server, this is likely to be a low priority for the Codex team to investigate. If someone from the community is interested in helping, we'd welcome an analysis of the problem and a proposed solution (not a PR, but a description here in the issue tracker).

  5. Emil-Sorensen commented on Feb 11, 2026

    @Emil-Sorensen

    Hi - I'm Emil, one of the co-founders of kapa.ai. We provide the hosted MCP infrastructure that Strapi (and many other companies) use for their docs servers.

    The root cause here is that Codex CLI doesn't include the resource query parameter in the OAuth authorization request. Per MCP spec Section 8, clients MUST implement RFC 8707 Resource Indicators and include resource in both authorization and token requests. We use this parameter to identify which tenant the user is authenticating for, since our auth server handles multiple MCP deployments.

    As @Chudroy confirmed, manually adding the resource parameter makes the flow work, which points to this being a client-side spec compliance gap.

    Link: https://modelcontextprotocol.io/specification/draft/basic/authorization#resource-parameter-implementation

    Image
  6. markbackman commented on Feb 11, 2026

    @markbackman

    Hi, I'm a maintainer of Pipecat. Today, we just released an MCP server using Kapa. We're getting reports of users having issues authenticating on Codex. I can confirm the MCP server works as expected on Claude Code.

    The root cause here is that Codex CLI doesn't include the resource query parameter in the OAuth authorization request.
    We'd be greatly appreciative if you resolved this issue in Codex 🙏

  7. etraut-openai commented on Feb 12, 2026

    @etraut-openai
    Contributor

    OK, it sounds like this has broader impact and is something that we need to prioritize. Thanks for the reports.

  8. markbackman commented on Feb 12, 2026

    @markbackman

    OK, it sounds like this has broader impact and is something that we need to prioritize. Thanks for the reports.

    Thank you! 🙇

  9. etraut-openai commented on Feb 12, 2026

    @etraut-openai
    Contributor

    PR is posted

  10. grahonan commented on Feb 12, 2026

    @grahonan

    Thank you @etraut-openai !

  11. ekarcnevets commented on Feb 17, 2026

    @ekarcnevets

    Hi @etraut-openai thanks for looking into this. I wanted to report that this issue is not fixed in the latest release which includes the rmcp 0.15 bump.

    The rmcp 0.15 bump (#11539) fixed an OAuth discovery fallback regression, but it seems not the missing resource parameter.

    Reproduction on Codex 0.102.0 (latest)

    $ codex --version
    codex-cli 0.102.0
    
    $ codex mcp add squad --url=https://mcp.meetsquad.ai/mcp
    Added global MCP server 'squad'.
    Detected OAuth support. Starting OAuth flow…
    Authorize `squad` by opening this URL in your browser:
    https://auth.meetsquad.ai/oauth/2.1/authorize?response_type=code&client_id=d5a2f5f48d84e3fc6bc3316b534a368c&state=zOEZEm8JY--f7nyXi_A_3A&code_challenge=1KdtEWF4KzjpmlCP0GwgsKEc5N3uGCKwAcoh7VT1Es0&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A52915%2Fcallback
    

    The authorization URL has no resource parameter. The browser callback returns:

    OAuth error: Missing or invalid resource.
    

    Fix is available upstream

    This was fixed in rmcp v0.16.0 (released today) via modelcontextprotocol/rust-sdk#651, which brings the SDK into compliance with the 2025-11-25 MCP auth spec including RFC 8707 resource parameter binding. Codex currently uses rmcp 0.15 (#11539) and just needs to bump to 0.16.

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

    authbugmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions