Skip to content

fix: work around rmcp OAuth discovery bug for remote MCP servers#8583

Open
jh-block wants to merge 3 commits intomainfrom
jhugo/fix-issue-8453
Open

fix: work around rmcp OAuth discovery bug for remote MCP servers#8583
jh-block wants to merge 3 commits intomainfrom
jhugo/fix-issue-8453

Conversation

@jh-block
Copy link
Copy Markdown
Collaborator

@jh-block jh-block commented Apr 16, 2026

Summary

Fixes the OAuth flow never opening a browser for remote MCP servers that require authentication (e.g. Attio). The root cause is an rmcp bug where resource metadata discovery fails fatally when the MCP server returns HTTP 200 with non-JSON content at its base URL, preventing fallback to .well-known/oauth-authorization-server discovery.

This PR adds a fallback in oauth_flow that catches the discovery failure and retries by fetching .well-known/oauth-authorization-server directly, using rmcp's public AuthorizationManager/AuthorizationSession APIs. It also logs the actual error when oauth_flow fails, instead of silently swallowing it.

Testing

Manual testing with the Attio MCP server (https://mcp.attio.com/mcp).

Related Issues

Relates to #8453
Upstream PR: modelcontextprotocol/rust-sdk#810

…vers

When a remote MCP server returns HTTP 200 with non-JSON content at its
base URL, rmcp's resource metadata discovery fatally errors instead of
falling through to .well-known/oauth-authorization-server discovery.
This prevents the OAuth browser flow from ever opening.

Add a fallback in oauth_flow that catches the discovery failure and
retries by fetching .well-known/oauth-authorization-server directly.
Also log the actual error when oauth_flow fails instead of silently
swallowing it.

Upstream fix: modelcontextprotocol/rust-sdk#810
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1637c3d154

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/oauth/mod.rs Outdated
Follow the MCP spec discovery flow in the fallback path:
1. Fetch Protected Resource Metadata from .well-known/oauth-protected-resource
   (path-specific then root, per RFC 9728)
2. Extract the authorization server URL from authorization_servers
3. Discover Authorization Server Metadata from that URL
   (trying RFC 8414 and OpenID Connect well-known endpoints)

This correctly handles cases where the authorization server is on a
different host from the MCP server, and path-based deployments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant