Skip to content

docs: correct the 401 scope note and test the refresh-token dead-end - #48

Merged
brkalow merged 2 commits into
mainfrom
manovotny/step-up-401-refresh-token
Nov 6, 2026
Merged

brkalow merged 2 commits into
mainfrom
manovotny/step-up-401-refresh-token

Conversation

@manovotny

Copy link
Copy Markdown
Contributor

Summary

Two gaps from reviewing clerk/clerk#3786. The README said a 401 usually names no scope, which is wrong for Next.js servers on mcp-handler. The step-up e2e test also never gave the client a refresh token, so it missed the case where the MCP SDK 1.x client can't step up.

Changes

  • README: a 401 names scopes only when the server adds them, as mcp-handler's withMcpAuth does from its requiredScopes. Otherwise, scopes_supported is what a client requests on first connection.
  • test/step-up.test.ts: adds a client holding a refresh token. The SDK 1.x client refreshes instead of redirecting, gets the same scopes back, and throws Server returned 403 after trying upscoping, so the user never reaches consent. Clerk issues refresh tokens by default, so real clients on 1.x land here.
  • Empty changeset: no package changes.

The new test pins current SDK behavior. It fails if a 1.x backport lands, and that's the cue to flip it to expect the redirect.

References

🤖 Generated with Claude Code

A 401 names scopes when the server adds them, which mcp-handler's
withMcpAuth does, so the README line was wrong for Next.js. The e2e
tokens had no refresh_token, so nothing exercised the SDK 1.x client
refreshing instead of redirecting.

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

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The README clarifies when a 401 challenge names scopes and what clients usually request when no scopes are named. The end-to-end test records token requests and adds coverage for an SDK 1.x client that refreshes its token but does not obtain additional scopes. The changeset adds empty frontmatter with no release metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • clerk/mcp-tools#46: Adds the step-up helper and end-to-end test that this change extends.
  • clerk/mcp-tools#44: Adds insufficient-scope challenges that trigger client step-up.
  • clerk/mcp-tools#43: Adds tool scope challenges and tests client redirects for under-scoped tokens.

Suggested reviewers: brkalow

Merge Risk: Low · up to 7ce3a

This PR changes documentation and tests only. The README guidance may mislead integrators whose clients use SDK 1.x with refresh tokens, and the new test does not fully prove that the retry uses the refreshed token. Both are worth fixing, but neither affects shipped runtime behavior.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Fold the scopes_supported fallback into one sentence, and scope the
first-connection claim to 401s that name no scopes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manovotny
manovotny marked this pull request as ready for review November 6, 2026 22:32

@brkalow brkalow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❤️

@brkalow
brkalow merged commit 6b8ca75 into main Nov 6, 2026
11 of 12 checks passed
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.

2 participants