Skip to content

feat(mcp): use https://capgo.app as the OAuth issuer - #3803

Merged
riderx merged 3 commits into
mainfrom
feat/mcp-oauth-issuer-capgo-app
Oct 21, 2026
Merged

riderx merged 3 commits into
mainfrom
feat/mcp-oauth-issuer-capgo-app

Conversation

@riderx

@riderx riderx commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Make https://capgo.app the OAuth issuer of the hosted MCP authorization server. Scanners and OAuth clients can then discover it on the main domain, as RFC 8414 requires. The endpoints don't move.

  • New MCP_OAUTH_ISSUER var (set to https://capgo.app in the prod wrangler env). When unset, the issuer falls back to the request origin, so preprod, alpha and local behave exactly as before.
  • New MCP_OAUTH_API_ORIGIN var (prod: https://api.capgo.app): the only API origin advertised for MCP OAuth (endpoints, resource, PRM URL), whichever hostname the request arrives on (e.g. api.usecapgo.com). Unset → request origin.
  • getIssuer() → config. A new getApiOrigin() keeps serving the authorize/token/register/revoke endpoints, the MCP resource and the WWW-Authenticate resource_metadata URL on the API origin.
  • Uses of the issuer: issuer in /.well-known/oauth-authorization-server, authorization_servers in the protected resource metadata, the RFC 9207 iss redirect parameter, and the issuer stored on mcp_oauth_requests (so approve/deny redirects send the same iss).
  • RFC 8414 §3.3: when the issuer is another origin, /.well-known/oauth-authorization-server (and its /mcp variant) on the API returns 404 instead of metadata with a mismatched issuer. The metadata is exposed at /mcp/oauth/metadata for capgo.app to serve.
  • Tokens are unchanged: still opaque API keys, and existing connections keep working.

⚠️ Deploy order

capgo.app must serve /.well-known/oauth-authorization-server from /mcp/oauth/metadata before this ships. Cap-go/website#1244 (merged) added the route, and Cap-go/website#1245 reads the new endpoint with a fallback. Deploy website#1245 first, then this PR. Otherwise the PRM points clients at an issuer with no metadata, and new MCP logins fail.

Note: very old MCP clients that skip protected resource metadata and read api.capgo.app/.well-known/oauth-authorization-server directly now get 404. Current clients use PRM and are unaffected.

Test plan

  • vitest run tests/mcp-oauth-issuer.unit.test.ts tests/mcp-remote.unit.test.ts: 31 pass (covers the single api.capgo.app origin across hostnames, the configured issuer, the 404 at the API well-known URL, /mcp/oauth/metadata, PRM and the WWW-Authenticate challenge)
  • bun run lint:backend
  • bun run typecheck:backend
  • After both deploys: connect an MCP client to https://api.capgo.app/mcp and complete the OAuth login
  • isitagentready scan for capgo.app

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Split the OAuth issuer from the API origin. MCP_OAUTH_ISSUER (prod:
https://capgo.app) is used for the issuer in authorization server
metadata, the iss authorization response parameter and the protected
resource metadata authorization_servers. The OAuth endpoints, the MCP
resource and the WWW-Authenticate challenge stay on the API origin.
Unset, the issuer falls back to the request origin as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 42babd74-4f86-4167-9de2-78f8a7827915
📥 Commits

Reviewing files that changed from the base of the PR and between 4db2023 and 9999d6d.

📒 Files selected for processing: 4
  • cloudflare_workers/api/wrangler.jsonc
  • supabase/functions/_backend/mcp/oauth.ts
  • tests/mcp-oauth-issuer.unit.test.ts
  • tests/mcp-remote.unit.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T11:50:44.172639Z 9999d6d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing feat/mcp-oauth-issuer-capgo-app (9999d6d) with main (1968349)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread supabase/functions/_backend/mcp/oauth.ts
RFC 8414 §3.3: when MCP_OAUTH_ISSUER is another origin (prod:
https://capgo.app), the API's /.well-known/oauth-authorization-server
returns 404 instead of metadata with a mismatched issuer. The metadata is
exposed at /mcp/oauth/metadata for the issuer origin to serve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Copy link
Copy Markdown

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: fba0a345bd

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread supabase/functions/_backend/mcp/oauth.ts
MCP_OAUTH_API_ORIGIN (prod: https://api.capgo.app) pins the OAuth
endpoints, the MCP resource and the protected resource metadata URL, so
requests reaching the worker through another hostname advertise the same
resource the capgo.app issuer metadata points at. Without it the request
origin is used, as before. The well-known AS metadata check still
compares the issuer with the actual request origin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread supabase/functions/_backend/mcp/oauth.ts
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@riderx
riderx merged commit 388eac4 into main Oct 21, 2026
74 of 75 checks passed
@riderx
riderx deleted the feat/mcp-oauth-issuer-capgo-app branch October 21, 2026 12:08

This branch was previously deployed

1 inactive deployment
deepsec-pr — 9999d6d4 Deployed Oct 21, 2026 by riderx via Scan PR changes #9462
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