Repository navigation
fix(oauth): default MCP resource when Gemini omits it - #948
Conversation
Gemini Spark custom MCP apps omit RFC 8707 resource on authorize, so grants
mint tokens with no audience and /mcp rejects them. Default resource to
{origin}/mcp when the client did not send one.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughOAuth authorization handling now supplies the application’s ChangesOAuth resource defaulting
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant handleAuthorizeRequest
participant resolveAuthRequest
participant getAppBaseUrl
Client->>handleAuthorizeRequest: Submit OAuth authorization request
handleAuthorizeRequest->>resolveAuthRequest: Resolve request with env
resolveAuthRequest->>getAppBaseUrl: Derive application base URL
getAppBaseUrl-->>resolveAuthRequest: Application base URL
resolveAuthRequest-->>handleAuthorizeRequest: Request with /mcp resource
handleAuthorizeRequest-->>Client: Authorization response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-948.kody-a99.workers.dev Worker: Mocks:
|
Summary
Gemini Spark custom MCP authorize requests omit RFC 8707
resource. That left grants without a resource, so token exchange minted tokens with no audience and/mcprejected them (invalid_token/ audience mismatch). After approve, Gemini saw “no resource” / failed to stay connected even though OAuth UI returned 200.This defaults
authRequest.resourceto{origin}/mcpwhen the client does not send one. Explicitresourcevalues (Claude, etc.) are unchanged.Test plan
resource) defaults tohttps://heykody.dev/mcpincompleteAuthorizationresourcehttps://heykody.dev/mcp(fresh authorize so the new grant gets/mcp)System recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@32bd8b8c· Head:34885e34Classification: extends — MCP OAuth authorize now fills a missing RFC 8707
resourceso grants/tokens carry an/mcpaudience.Primitives touched
mcp-oauth{origin}/mcpwhen authorize omitsresourceapp-sessionsSystem map
Gemini authorize → approve → grant with default MCP resource → token audience accepted by
/mcp.Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Before / after
resource)/mcp401{origin}/mcp→ token audience matches/mcpresourceset)Summary by CodeRabbit
Bug Fixes
Tests