Skip to content

fix(mcp): Check events, traces and replays an ID alone names against the session's project - #2541

Open
sentry-junior[bot] wants to merge 5 commits into
fix/mcp-commands-numeric-issue-scopefrom
fix/mcp-commands-opaque-id-scope
Open

sentry-junior[bot] wants to merge 5 commits into
fix/mcp-commands-numeric-issue-scopefrom
fix/mcp-commands-opaque-id-scope

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #2527 for #2237. Stacked on #2527.

#2527 checks issues. In a project-scoped sentry mcp --commands session (acme/web), events, traces and replays fetched by an opaque ID still reached other projects:

  • event view <event-id> 404s in acme/web, then its fallback finds the event org-wide (/eventids/) and shows it. The same happens with event view acme/ <event-id>.
  • trace view <trace-id> reads the trace org-wide.
  • replay view <replay-id> checked the replay's project only when the call named a project.

Changes

  • target-scope.ts. The checks now take what they check (Issue 123, Event abc) for the error. The new assertProjectInScope(org, projectSlug, subject) covers anything with a project slug. assertIssueInScope now uses it.
  • Events. getEvent refuses a project outside the scope before the request. resolveEventInOrg refuses another org before the request and another project after it. event view used to swallow every non-auth error in its same-org fallback. It now passes a scope refusal through.
  • Traces. getDetailedTrace refuses another org. In a project scope, it also refuses a trace with no span in the session's project, at any depth. trace view, span view and the span tree in event view all read traces through it.
  • Replays. resolveReplay refuses another org. validateReplayProjectScope, which replay view and replay download already run, now also compares the replay with the session's project. A replay without a project, such as an archived one, is refused in a project scope.

Open question: a trace that has a span in the session's project is returned whole, including spans from the other projects it calls into. Sentry's trace view works the same way, and a distributed trace isn't useful cut down to one project. If the session should only ever see its own project's spans, the next step is to filter spans instead of checking the trace.

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot added this pull request to stack #1926 November 26, 2026 19:30
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 28, 2026 1:45am UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 28, 2026 1:45am UTC

Request Review

@BYK
BYK marked this pull request as ready for review November 26, 2026 23:07
@BYK
BYK requested a review from a team as a code owner November 26, 2026 23:07
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 26, 2026
…the session's project

A project-scoped `sentry mcp --commands` session still reached other
projects through IDs that name no project. `event view <event-id>` fell
back to the org-wide event ID lookup, `trace view <trace-id>` reads a
trace org-wide, and `replay view <replay-id>` checked the replay's
project only when the call named one.

The scope checks in `target-scope.ts` now take what they check (`Issue
123`, `Event abc`), and `assertProjectInScope` covers anything with a
project slug:

- `getEvent` and `resolveEventInOrg` refuse an event outside the scope,
  and `event view` no longer swallows that refusal in its fallbacks.
- `getDetailedTrace` refuses a trace with no span in the session's
  project. A trace that has one keeps the spans of the projects it
  calls into.
- `resolveReplay` refuses another organization, and the replay project
  check also compares the replay with the session's project. A replay
  without a project is refused in a project scope.

Refs #2237

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/cli/src/lib/target-scope.ts Resolved
…t list

`replay view --web` opened the replay before `validateReplayProjectScope`
ran, so a project-scoped session could open another project's replay
that an ID alone names. The scope check now runs first.

A refused event, trace or replay suggested `issue list`. The hint now
names the list command of what was refused (`event list acme/web`).

Refs #2237

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 719d201. Configure here.

Comment thread packages/cli/src/lib/target-scope.ts Resolved
`event list` takes an issue, not a project, and `trace list` needs a
project. A refused event now suggests `issue list`, and a refused trace
suggests `trace list` only in a project scope.

Refs #2237

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — db0f660e Deployed Nov 28, 2026 by vercel[bot]
Preview – sentry-local — db0f660e Deployed Nov 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant