Repository navigation
fix(mcp): Limit sentry mcp --commands sessions to their target - #2554
Open
sentry-junior[bot] wants to merge 1 commit into
Open
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
The `--commands` pieces of the scope fix for #2237, split out when the rest of the stack moved off #1922 onto `main`: - The stdio runner passes `limitToTarget: true` to the CLI SDK, so the session's org and project are a limit, not only defaults. - The command-surface constraints note that an ID alone (a numeric issue ID, an event, trace or replay ID) is checked by the runner. - `command-surface-scope.test.ts` runs the commands of a project-scoped session against a mocked Sentry API and checks each kind of ID. - The architecture overview describes what the transport scope does for a `--commands` session. These need `limitToTarget` and the transport scope from the stack that starts at #2527, so they build once #1922 has that stack. Refs #2237 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions Bot
pushed a commit
to Fields-Education/sentry-mcp
that referenced
this pull request
Nov 30, 2026
…ect (getsentry#2527) Refs getsentry#2237. Based on `main`. In a project-scoped `sentry mcp --commands` session (`acme/web`), the command surface checks the targets a call names. Some identifiers name no project: a numeric issue ID, an issue URL, a share link, a selector such as `@latest`, or search text. The session's org and project reached the CLI only as defaults (`SENTRY_ORG`/`SENTRY_PROJECT`), so nothing compared the issue the CLI found with the session. Examples that got through: - `issue view 12345` read an issue in another project. - `issue resolve 12345` changed an issue in another project. - `issue view @latest` and `feedback view @latest` picked the newest issue in the whole organization. - `event view https://acme.sentry.io/issues/12345/` read another project's events. As proposed in the issue, the CLI now checks the issue after it looks it up and before a command reads or changes anything. **Changes** - **SDK option.** New `SentryOptions.limitToTarget` makes `org`/`project` a limit instead of a default. It defaults to `true`, and `limitToTarget: false` opts out. The SDK passes it to the invocation as the internal env vars `SENTRY_CLI_SCOPE_ORG`/`SENTRY_CLI_SCOPE_PROJECT`. The `sentry mcp --commands` runner wiring that sets it now lives in getsentry#2554. - **Check helpers.** `lib/target-scope.ts` refuses an issue in another organization or project with a `ResolutionError`. In a project scope, an issue whose project is unknown is refused too. - **Lookups by ID.** `getIssueInOrg` and `getIssueByShortId` refuse another organization before the request and another project after it. Every lookup by ID goes through these two: numeric, `<org>/<id>`, URL, share link, short ID and alias. - **Selectors and search.** `findSelectorIssue`, issue search and the Feedback `@latest` selector look only in the session's project, then check the result. - **`event view`.** For a numeric issue or an issue URL, it checks the issue before it reads the issue's events. Before, its project lookup was best-effort, and it was skipped when the call named a project. - **Docs.** The SDK option table (`library-usage.md`) now describes the limit. The `--commands` notes (`docs/architecture/overview.md`, mcp-core `constraints.ts`) now live in getsentry#2554. **Breaking change:** `createSentrySDK({ org, project })` callers now get `org`/`project` as a limit, not just a default, so a command that reaches another organization or project fails. Pass `limitToTarget: false` to keep the old behavior. **Follow-up:** events, traces and replays fetched by an opaque ID (`event view <event-id>`, `trace view <trace-id>`, `replay view <replay-id>`) are not checked against the session's project yet. This PR covers issue lookups only (Feedback included). <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A30387dbb15a73c1ea95ce25e5f09b56a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A30387dbb15a73c1ea95ce25e5f09b56a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A30387dbb15a73c1ea95ce25e5f09b56a/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
Contributor
|
This PR has had no activity for 3 days. It closes in 2 days unless someone pushes, comments, or adds the |
BYK
approved these changes
Nov 30, 2026
This branch had an error being 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.
Refs #2237. Based on #1922.
The scope fix for #2237 (#2527 → #2541 → #2549 → #2552) moved off #1922 onto
main. This PR keeps the parts that only make sense with #1922'ssentry mcp --commandssurface:packages/cli/src/lib/mcp/command-surface.ts) passeslimitToTarget: truetocreateSentrySDK(), so the session's org and project are a limit, not only defaults.constraints.tsnotes that an ID alone (a numeric issue ID, an event, trace or replay ID) names no project, so the runner checks what it finds.--commandssection ofdocs/architecture/overview.mddescribes the transport scope and thex-sentry-project-scopedeclarations.limitToTargetand the transport scope come from #2527–#2552, which #1922 doesn't have yet. Keep this a draft until they land onmainand #1922 picks them up.via @BYK.
--
View Session [Sentry]