Repository navigation
feat(mcp): Accept an <org>/<project> target for sentry mcp - #1800
Merged
Merged
Conversation
`sentry mcp [<org>/[<project>]]` scopes the server like --org and --project do: `acme/` limits every call to an organization, `acme/web` to a project. The target goes through the CLI's shared org/project parser (parseOrgProjectInput, the side-effect-free parseOrgProjectArg). A bare `acme` is refused with a hint to pass `acme/`, since every other command reads it as a project search. URLs are refused with a hint to set SENTRY_URL, since the host comes from the environment. A target and --org/--project (or their deprecated aliases) that disagree are a ValidationError, like the existing alias conflicts in mergeMcpArgs. Where `mcp` is the default command (`@sentry/mcp-server`), a first word that names no route is the target, so `npx @sentry/mcp-server acme/web` starts the server without the CLI's telemetry. Route names still win. Refs #1357, #1731 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 2, 2026
This was referenced Nov 2, 2026
This branch was successfully 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.
Follow-up to #1731, part of the CLI-first refactor in #1357.
sentry mcpnow takes the same<org>/<project>target as the rest of the CLI:Behavior
[<org>/[<project>]]positional is read by the CLI's shared org/project parser. That'sparseOrgProjectInput, the side-effect-free form ofparseOrgProjectArg, so a pasted URL can't change the server context. Only forms that name an org are accepted:acme/sets the org, andacme/websets the org and project.acmeis refused with a hint to passacme/, because every other command reads a bare slug as a project search.scheme://…targets are refused with a hint to setSENTRY_URL, because the host comes from env. The check runs before the shared parser, which doesn't recognize URLs likehttps://acme.sentry.io/issues/.acme/web/api,acme/web,api, and invalid slugs (?,#, …) are refused.--org/--projectand their deprecated--organization-slug/--project-slugaliases still work. If a target and a flag disagree, that's aValidationError, like the existing alias conflicts inmergeMcpArgs. Matching values are fine.acme/combined with--project=webscopes toacme/web.@sentry/mcp-server):isMcpInvocation()treats a first word that names no route asmcp's target. This matches Stricli, which routes an unknown first token to the default command as a positional. Sonpx @sentry/mcp-server acme/webstarts the server without the CLI's telemetry or recovery middleware. Route names (mcp,auth,help) still win over a target.Ambiguity with route names
Under
@sentry/mcp-server, a word that matches a route is always the route. An org that happens to be calledauthhas to be written asauth/, which already gets parsed as a target because it isn't a route name. A bare word is never a valid target anyway. Sonpx @sentry/mcp-server issue(someone trying a CLI command the slim bundle doesn't have) now reaches the target parser and fails with'issue' names no command, and a target needs an organization: ….issue listfails on Stricli's arity check (Too many arguments, expected 1 but encountered "list"). Before this change, both failed withexpected 0 arguments. The bundle test now asserts these messages.Docs
--helpexamples, the generated command docs, and thesentry-cliskill (SKILL.md,references/mcp.md) are all regenerated.mcpdocs fragment has a new "Limit the server to an organization or project" section with an MCP client config.docs/testing/stdio.mdlists the target next to--org/--project.Checks
pnpm run lint,pnpm run check:generated, andpnpm run docs:checkpass.tsc --noEmitforpackages/clipasses, and the workspacepnpm run tscshowed no type errors.test/lib/mcp/*,mcp-command,mcp-start,mcp-auth,mcp-login,arg-parsing(unit and property),completion-coverage,completions.property,fragment-commands,generate-skill-markdown,cli-startup,app-identity,help-graphics, andtest/commands(148 files).test/lib/completions.test.tshas two EACCES/EPERM cases that fail the same way onmain, so they're unrelated to this change.@sentry/mcp-serverbundle builds at 3,639,734 bytes, +1.4 KB overmainand under the 3.75 MiB budget.test:bundlepasses 15/15.via @BYK.
--
View Session in Sentry