whoami returns a bare HTTP 400 when the token has no user behind it (org auth tokens)

Offen Anfängerfreundlich
#2,315 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
75/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
api, authentication

Rechercherichtung

Lies packages/mcp-core/src/internal/error-handling.ts und verfolge, wie whoami eine 400-Antwort von /auth/ behandelt. Aktualisiere die für diesen Fall angezeigte Fehlermeldung so, dass sie erklärt, dass dem Token kein Benutzer zugeordnet ist, und ein persönliches Token oder OAuth empfiehlt. Die Aufgabe ist erledigt, wenn die Fehlermeldung diese Hinweise gibt und die bestehende allgemeine Fehlerbehandlung für andere Fehler weiterhin geeignet ist; im Issue wird keine Testdatei genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

mcp-feedback-pattern

An agent connected to the hosted MCP with a direct Sentry-Bearer token got 403s naming org:read on find_organizations and find_projects and event:read on search_issues, and then whoami failed with a bare HTTP 400 Bad Request. It concluded the token "has no usable scopes" and stopped. Reported through submit_feedback_to_sentry_team (MCP 0.42.0).

Likely token type (inference: we can't see the token). These failures fit an org auth token (sntrys_...):

  • Org auth tokens carry only org:ci. It's the only allowed scope (sentry src/sentry/models/orgauthtoken.py:32-36), so every read tool gets an insufficient_scope 403. Since getsentry/toolkit#2222, the MCP names the missing scopes correctly.
  • Org auth tokens authenticate with no user (OrgAuthTokenAuthentication passes None as the user, sentry src/sentry/api/authentication.py:751-787). GET /api/0/auth/ then returns a bodiless 400 when request.user isn't authenticated (sentry src/sentry/api/endpoints/auth_index.py:63-65).

MCP gap. whoami passes that 400 through the generic Input Error template ("There was an HTTP 400 error... trying again", packages/mcp-core/src/internal/error-handling.ts). That message doesn't tell the agent the token isn't tied to a user, or that org auth tokens can't drive the MCP.

Fix. whoami should explain a 400 from /auth/: the token isn't tied to a user, org auth tokens only carry org:ci, so connect with a personal token or OAuth.

Possible follow-up, not in the fix: reject sntrys_ tokens up front in Sentry-Bearer mode, since no read tool can work with org:ci alone.

Reports: 1

via automation evt_905b9c478746fd9deeb853f85ad7441b · Run ID dispatch_d428b39c5339ad27cbfcee6c1a8f7e77.

--

View Session [Sentry]

Vorherrschende Sprache
TypeScript
Sterne
975
Forks
189
Ø Merge
19 Std. 57 Min.
Gemergte PRs (30 T.)
542

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/toolkit

Alle Issues in getsentry/toolkit

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.