Skip to content

MCP OAuth: token refresh omits resource parameter → Atlassian returns 401 #34592

Closed as not planned

Description

@SharmilaMohan91

Description

When opencode refreshes an OAuth token for an MCP server (e.g., Atlassian), it does not include the resource parameter (RFC 9728) in the token refresh request. Atlassian's OAuth server requires the resource parameter to bind the token to the correct audience. Without it, the refreshed token is rejected with HTTP 401 by the MCP endpoint.

A fresh token obtained manually with the resource parameter works correctly (returns 400 for protocol reasons, not 401 for auth). But once opencode auto-refreshes the token, it breaks again.

This differs from #22095 (which is about webfetch, not MCP OAuth refresh).

Plugins

Atlassian MCP (remote OAuth)

OpenCode version

1.17.11

Steps to reproduce

  1. Configure Atlassian MCP server with OAuth
  2. Complete initial OAuth flow (works)
  3. Wait for token to expire (or restart opencode)
  4. opencode refreshes token without resource parameter
  5. All subsequent MCP calls fail with 401

Operating System

macOS

Activity

  1. github-actions commented on Jun 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If you believe your issue is distinct (e.g., the resource parameter omission is a separate bug from the refresh not being triggered), please clarify so maintainers can track them separately.

  2. fengjikui commented on Jul 10, 2026

    @fengjikui
    Contributor

    I traced this against current dev and the version reported here (1.17.11). OpenCode 1.17.11 already pins @modelcontextprotocol/sdk 1.29.0; in that SDK, authInternal() passes the selected resource to refreshAuthorization(), and executeTokenRequest() writes it into the form body. A focused invocation produced:

    grant_type=refresh_token&refresh_token=refresh-old&resource=https%3A%2F%2Fmcp.atlassian.com%2Fv1%2Fmcp%2Fauthv2&client_id=client
    

    The remaining discriminator appears to be the configured Atlassian endpoint. Atlassian's current documented endpoint, https://mcp.atlassian.com/v1/mcp/authv2, returns a WWW-Authenticate header with resource_metadata, and that metadata declares resource as the same endpoint. The legacy /v1/sse and /v1/mcp endpoints currently return no resource_metadata, and their derived RFC 9728 well-known URLs return 404, so the SDK has no validated resource to add. Current setup guide: https://support.atlassian.com/atlassian-rovo-mcp-server/docs/setting-up-ides/

    Could you confirm the exact MCP URL that produced the trace? If it was a legacy endpoint, please retest with /v1/mcp/authv2. If authv2 still omits resource, a redacted token-request trace plus the preceding WWW-Authenticate header would show whether the loss is during metadata discovery or request construction.

  3. SharmilaMohan91 commented on Jul 13, 2026

    @SharmilaMohan91
    Author

    I'm using /v1/mcp/authv2. Token refresh is not happening automatically — I'm being re-prompted for auth when the token expires. This suggests the refresh request is being rejected.

  4. github-actions commented on Sep 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions