Skip to content

Challenge MCP clients when the site rejects their bearer token - #4807

Open
spastorelli wants to merge 2 commits into
mainfrom
steeve/rnd-14251-return-an-oauth-challenge-when-the-site
Open

spastorelli wants to merge 2 commits into
mainfrom
steeve/rnd-14251-return-an-oauth-challenge-when-the-site

Conversation

@spastorelli

Copy link
Copy Markdown
Collaborator

Proposed changes

On a visitor-auth site, a request to ~gitbook/mcp or ~gitbook/mcp/auth with a bearer token the site rejects now gets the same 401 + WWW-Authenticate challenge as a request with no token, instead of a plain 401. MCP clients can then authorize again.

Only applies when the lookup fails with 401, the token came from the Authorization header (or access_token), and the path is an OAuth protected resource. Other errors and paths are unchanged.

Validation: new e2e cases in tests/mcp.test.ts (fail before the change, pass after) and the full tests/mcp.test.ts file, run against a local dev server; turbo run typecheck --filter=gitbook.

Linear: RND-14251

Changelog

  • [Fix] MCP clients are asked to authorize again when a visitor-auth site rejects their token.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

RND-14251

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c75b0bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@argos-ci

argos-ci Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2-cloudflare (Inspect) 👍 Approved by spastorelli 5 changed, 7 ignored Nov 18, 2026, 6:33 PM
customers-v2-vercel (Inspect) 👍 Approved by spastorelli 6 changed, 2 ignored Nov 18, 2026, 6:29 PM
v2-cloudflare (Inspect) 👍 Approved by spastorelli 4 changed, 4 ignored Nov 18, 2026, 6:35 PM
v2-vercel (Inspect) 👍 Approved by spastorelli 3 changed, 5 ignored Nov 18, 2026, 6:31 PM

@github-actions

Copy link
Copy Markdown
Contributor

Style invalidation on a large API reference

Elements restyled by opening one popup on the Snyk API reference. A share near or above 100% means the insertion restyles the whole document.

interaction restyled page share budget
openapi-select 7 12,234 0.1% 25% ✅
search 648 12,234 5.3% 125% ✅

@spastorelli spastorelli changed the title Challenge MCP clients when the site rejects their bearer token (RND-14251) Challenge MCP clients when the site rejects their bearer token Nov 18, 2026

This branch was successfully deployed

2 active 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.

2 participants