Repository navigation
fix(mcp): Name the missing scopes when Sentry answers 403 insufficient_scope - #2222
Merged
Merged
Conversation
…t_scope Sentry names the scopes an endpoint accepts only in a 403's WWW-Authenticate insufficient_scope challenge. The MCP dropped it and told agents to fix their input and try again, which cannot work with the same token (93 analyze_issue_with_seer calls across 9 orgs in 14 days). @sentry/api now carries the scopes on ApiPermissionError.acceptedScopes. formatErrorForUser and embedded agent tools return a Missing Permission message that names them and says retrying won't help, also when a tool rewrapped the error. The CLI drops its copy of the challenge parser for the shared one; the CLI's own 403 guidance is unchanged, and its MCP server gets the fix through mcp-core. Fixes #2208 Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 12, 2026
1.83.0 carries the insufficient_scope challenge's scopes on ApiPermissionError.acceptedScopes (getsentry/sentry-api-schema#146). Co-Authored-By: Claude <[email protected]>
…e-403 # Conflicts: # packages/mcp-core/src/internal/error-handling.test.ts # packages/mcp-core/src/internal/error-handling.ts
…e-403 # Conflicts: # pnpm-lock.yaml
…e-403 # Conflicts: # pnpm-lock.yaml
BYK
approved these changes
Nov 13, 2026
This was referenced Nov 17, 2026
7 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2208.
When a token lacks the scope an endpoint needs, Sentry returns a 403 with DRF's generic detail and lists the accepted scopes only in
WWW-Authenticate: Bearer error="insufficient_scope", scope="...". The MCP dropped that header and showed the generic Input Error template ("…address the concern and try again"), which can't work with the same token. For example, starting autofix inanalyze_issue_with_seerneedsevent:write,event:admin, orseer:write. Sentry already sends the challenge for that endpoint (getsentry/sentry#118612), so no backend change is needed.@sentry/api1.83.0 (getsentry/sentry-api-schema#146) reads the header in the shared request core:ApiPermissionError.acceptedScopesholds the scopes, and itstoUserMessage()names them. This PR bumps to 1.83.0 and uses that:formatErrorForUserreturns a Missing Permission message that names the accepted scopes and says retrying with the same token won't help. It also finds the error when a tool rewrapped it ascause(e.g.withApiErrorHandling'sUserInputError). Embedded agent tools get the same message, without the "try again" advice.parseInsufficientScopeChallengeinstead of a local copy, so behavior is the same.sentry mcpgets the MCP fix through mcp-core.The message only names the scopes the endpoint accepts, which are the same for every caller. Nothing about the user, role, org, or token is added. A role-based 403 has no challenge and keeps the old message.
Out of scope:
analyze_issue_with_seerstill declaresrequiredScopes: []. Gating the tool onevent:writewould hide it from grants that can read Seer results, so that's a product call for a separate change.via @BYK.
--
View Session [Sentry]