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

未关闭 适合新手
#2,315 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

阅读 packages/mcp-core/src/internal/error-handling.ts,追踪 whoami 如何处理来自 /auth/ 的 400 响应。更新此情况下显示的错误,说明该令牌没有关联的用户,并建议使用个人令牌或 OAuth。当错误提供了这些指导,且现有的通用处理方式仍适用于其他错误时,即为完成;issue 未指定测试文件。

由索引模型根据 Issue 内容生成。

描述

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]

主要语言
TypeScript
星标
975
派生
189
平均合并
19 小时 57 分钟
30 天内合并 PR
542

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/toolkit 的其他 Issue

查看 getsentry/toolkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。