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

Ouverte Adaptée aux débutants
#2,315 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
75/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript
Domaine
api, authentication

Piste de recherche

Lisez packages/mcp-core/src/internal/error-handling.ts et suivez la façon dont whoami traite une réponse 400 de /auth/. Modifiez le message d’erreur affiché dans ce cas pour expliquer qu’aucun utilisateur n’est associé au jeton et recommander un jeton personnel ou OAuth. La tâche est terminée lorsque l’erreur fournit ces indications et que la gestion générique existante reste adaptée aux autres erreurs ; l’issue ne mentionne aucun fichier de test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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]

Langage dominant
TypeScript
Étoiles
975
Forks
189
Merge moyen
19 h 57 min
PR mergées (30 j)
542

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de getsentry/toolkit

Toutes les issues de getsentry/toolkit

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.