Skip to content

fix(auth): accept /mcp alias as OAuth audience - #6078

Merged
saddlepaddle merged 1 commit into
mainfrom
mcp-rework/mcp-alias-audience
Jul 31, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
mcp-rework/mcp-alias-audience

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

First step toward making api.superset.sh/mcp the canonical MCP URL (de-versioning the v2 path).

/mcp re-exports the v2 MCP handler and marketing llms.txt already advertises it as an alias — but it was missing from validAudiences (token issuance) and from the mcp-v2 verifier's audience list. An OAuth client that used the alias as its RFC 8707 resource got working discovery, a successful consent flow, and then every token rejected.

  • packages/auth: add ${API_URL}/mcp to validAudiences
  • packages/mcp-v2: add it to the verification audience list

The remaining canonical-URL flip (docs, .well-known, server card, openapi advertising /mcp first; /api/v2/agent/mcp kept forever as legacy alias) rides with the A3 transport-hygiene PR. Both URLs become declared OAuth resources in the B2 protected-resources migration, which removes these duplicated lists entirely.

Note: may need a trivial conflict resolution with #6077, which removes the adjacent v1 audience line.

Verify: OAuth flow with resource https://api.superset.sh/mcp issues tokens that pass tool calls on both URLs.

https://claude.ai/code/session_01Kub4p3Eim9pc1qaRRmGea2


Open in Stage

Summary by cubic

Accept /mcp as a valid OAuth audience so clients using the alias get tokens that verify with the v2 MCP handler. Adds ${API_URL}/mcp to both issuance and verification audience lists.

  • Bug Fixes
    • packages/auth: add ${API_URL}/mcp to validAudiences.
    • packages/mcp-v2: add ${API_URL}/mcp to JWT verification audiences.

Written for commit d30fb0b. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved OAuth authentication compatibility for MCP requests by accepting the MCP API endpoint as a valid token audience.
    • Prevented valid access tokens from being rejected when issued for the MCP endpoint.

@ghost

ghost commented Jul 31, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 2 individual chapters for you:

Title
1 Enable MCP alias in OAuth token issuance
2 Accept MCP alias during JWT verification
Open in Stage

Chapters generated by Stage for commit d30fb0b on Jul 31, 2026 10:00pm UTC.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OAuth audience validation now accepts the API /mcp URL in both the OAuth provider and MCP authentication paths. Existing valid audiences remain supported.

Changes

OAuth MCP audience support

Layer / File(s) Summary
MCP OAuth audience validation
packages/auth/src/server.ts, packages/mcp-v2/src/auth.ts
The OAuth provider and MCP authentication accept ${apiUrl}/mcp while retaining the existing valid audiences.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the OAuth audience fix and follows the repository's conventional commit format.
Description check ✅ Passed The description explains the problem, changes, scope, planned follow-up work, and verification scenario.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mcp-rework/mcp-alias-audience

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/api/.vercel/project.json`:
- Around line 1-5: Remove the tracked .vercel/project.json and
.vercel/README.txt files from the PR, and preserve the existing ignore rule for
the .vercel directory so its project metadata remains uncommitted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b20db264-b479-4a30-9fa8-8ff3b3dd95b8

📥 Commits

Reviewing files that changed from the base of the PR and between 9c3cf93 and 6bb00c5.

📒 Files selected for processing (4)
  • apps/api/.vercel/README.txt
  • apps/api/.vercel/project.json
  • packages/auth/src/server.ts
  • packages/mcp-v2/src/auth.ts

Comment thread apps/api/.vercel/project.json Outdated
Comment on lines +1 to +5
{
"projectId": "prj_YPtna5dYgtR1iSaMhNawb6zs9TN6",
"orgId": "team_5CLWP9cJw0fMNffIbyM6EVwM",
"projectName": "api"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not commit .vercel project metadata.

apps/api/.vercel/README.txt states that .vercel should not be shared and should be ignored. This change commits projectId and orgId anyway. A checked-in project.json can cause Vercel commands from apps/api to target this linked project across all checkouts.

Remove both .vercel files from the PR and keep the directory ignored.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/.vercel/project.json` around lines 1 - 5, Remove the tracked
.vercel/project.json and .vercel/README.txt files from the PR, and preserve the
existing ignore rule for the .vercel directory so its project metadata remains
uncommitted.

The /mcp alias serves the v2 MCP handler and is advertised in
llms.txt, but was absent from both audience lists — a client that
registered with the alias as its resource got working discovery and
rejected tokens.

Claude-Session: https://claude.ai/code/session_01Kub4p3Eim9pc1qaRRmGea2
@saddlepaddle
saddlepaddle force-pushed the mcp-rework/mcp-alias-audience branch from 6bb00c5 to d30fb0b Compare July 31, 2026 22:00
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

This branch was previously deployed

1 inactive deployment
preview — d30fb0ba Deployed Jul 31, 2026 by saddlepaddle via Deploy Admin #6953
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