Repository navigation
feat(mcp-server): Ship @sentry/mcp-server as a slim bundle that shares CLI auth - #1731
sentry-junior[bot] wants to merge 49 commits into
Conversation
Move the stdio MCP host into the CLI so `sentry mcp` is the only local server. The stdio transport moves to mcp-core; flag/env parsing, usage, and server startup move to packages/cli/src/lib/mcp/. The standalone device-code auth and token cache are deleted in favor of CLI auth. `sentry mcp` keeps every standalone flag and env var, and accepts `--access-token` / `SENTRY_ACCESS_TOKEN` as a static, never-refreshed token that still goes through host scoping. Lock the dependency direction (cli -> mcp-core -> toolkit-core) with an oxlint import ban and a workspace manifest cycle check, move the MCP registry entry to the `sentry` package, and reduce @sentry/mcp-server to a deprecation shim for one last release. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
The doc example checker reads backticked sentry commands in the generated configuration page and does not know about `sentry mcp` passthrough flags. Co-Authored-By: BYK <burak.kaya@sentry.io>
The retired package fixed the SDK environment to "stdio" at build time. Co-Authored-By: BYK <burak.kaya@sentry.io>
…nippet Tool handlers read mcp-core's own copy of the server context, so updating the host's context after a refresh had no effect. onUpstreamUnauthorized can now return the new token, and mcp-core stores it where handlers read it. The fx profile snippet also ran plain `npx sentry@latest`. Co-Authored-By: BYK <burak.kaya@sentry.io>
…-package Co-Authored-By: BYK <burak.kaya@sentry.io>
Oxlint replaces a rule's options per override, so the toolkit-core browser override silently dropped the earlier CLI ban. Carry the ban there and test the last matching override for each package. Co-Authored-By: BYK <burak.kaya@sentry.io>
…-package # Conflicts: # pnpm-lock.yaml Co-Authored-By: BYK <burak.kaya@sentry.io>
Bundle the CLI's stdio MCP server into one dependency-free file instead of forwarding to the sentry CLI. The package keeps its flags, env vars, and self-hosted support, and adds a plain-text `sentry-mcp auth login`. The bundle script keeps CLI-only code out (commands, markdown renderer, agent skills, completions, terminal images, Ink UI, debug files) and drops the SQLite WASM fallback, so the package requires Node.js 22.15+. It fails the build if a CLI-only module reaches the output or the file exceeds 4.5 MB. Co-Authored-By: BYK <burak.kaya@sentry.io>
These invocations finish like any other drained command but skipped the force-exit backstop and dispatcher close that runCli applies, so leftover handles could keep the process alive on macOS. startMcpServer now reports whether a server is running, and runMcpServer and the standalone auth entry release resources whenever the invocation is finite.
`commands/mcp.ts` imported `@sentry/mcp-core/skills` for its help text, so loading any command needed mcp-core's build output. Docs generation (`sentry-cli-docs`, cli-build's docs job) and a fresh `pnpm run cli` load every command without building mcp-core, and failed. Copy the skill names into the command and guard the copy with a test. Co-Authored-By: BYK <burak.kaya@sentry.io>
Every caller (sentry mcp, the Cloudflare worker, the eval mock server) already asked for SDK v2, so buildServer() now always builds a v2 McpServer and the sdkVersion option, its overloads, and the v1 branch are gone. mcp-core's remaining SDK v1 imports were types; they now come from @modelcontextprotocol/server, and the unused RegisteredToolHandlerExtra type is deleted. @modelcontextprotocol/sdk moves to mcp-core's devDependencies (tests drive the server with its in-memory client) and leaves mcp-server-evals, which never imported it. The @sentry/mcp-server bundle no longer needs its SDK v1 stub, and now fails if any @modelcontextprotocol/sdk module reaches it. The CLI bundle drops SDK v1's server, zod-compat, its ajv, and zod-to-json-schema: dist/index.cjs goes from 7,426,174 to 7,203,971 bytes. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Everything we bundle builds Zod 4 schemas, but two dependencies still import zod/v3 for Zod 3 inputs: @ai-sdk/provider-utils (zod3Schema and its copy of zod-to-json-schema) and @mastra/schema-compat (its Zod 3 converter, plus an instanceof z3.ZodType check in isZodV3). sentry init only uses Mastra's workflow client, which converts no schemas. zodV3StubPlugin replaces zod/v3 with a stub shared by script/bundle.ts, script/build.ts, and the @sentry/mcp-server bundle. ZodType stays a class so the instanceof check is false, and ZodFirstPartyTypeKind throws a clear error if a Zod 3 schema ever reaches a converter. The test bundles the real Mastra client and provider-utils, runs a workflow create/start, converts Zod 4 and JSON schemas, and checks no zod/v3 module is included. CLI dist/index.cjs: 7,203,971 -> 7,142,739 bytes. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`sentry mcp` and `@sentry/mcp-server` take a token in --access-token, but setFlagContext only redacted `token`, so the value became a `flag.access-token` tag. Add it to the flag and argv redaction lists. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
--access-token and SENTRY_ACCESS_TOKEN used to bypass the CLI's credential resolution with a static-token path of their own. They now run the server as if SENTRY_AUTH_TOKEN=<token> and SENTRY_FORCE_ENV_TOKEN=1 were set: the token goes into an env copy (withEnv), so it takes the CLI's env-token path, wins over a stored login, and replaces any SENTRY_AUTH_TOKEN/SENTRY_TOKEN already set, since the flag is the explicit choice. The flag wins over SENTRY_ACCESS_TOKEN. The copy's URL is pinned to the --host/--url target, as the old static token was; an org token's claim must still match it. The .sentryclirc check runs against the invocation's own credentials first. Either one prints a single deprecation warning on stderr (stdout is the MCP transport) that never includes the token. resolveStaticMcpAccessToken and the accessToken config fields are gone. The help text, stdio-auth, READMEs, server.json, and the testing docs now lead with SENTRY_AUTH_TOKEN (plus SENTRY_FORCE_ENV_TOKEN=1, and SENTRY_HOST/SENTRY_URL for self-hosted). The test client and the eval scorer launch the server with those env vars instead of --access-token. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
| const server = new McpServer({ | ||
| name: MCP_SERVER_NAME, | ||
| version: LIB_VERSION, | ||
| }; | ||
|
|
||
| if (sdkVersion === "v2") { | ||
| const server = new ModernMcpServer(serverInfo); | ||
| const registrations = configureServer({ | ||
| server, | ||
| context: contextWithModes, | ||
| experimentalMode, | ||
| tools: customTools, | ||
| }); | ||
| for (const { name, config, handler } of registrations) { | ||
| server.registerTool(name, config, handler); | ||
| } | ||
| if (registrations.length > 0) { | ||
| server.server.registerCapabilities({ tools: { listChanged: false } }); | ||
| } | ||
| return wrapMcpServerWithSentry(server); | ||
| } | ||
|
|
||
| const server = new LegacyMcpServer(serverInfo); | ||
| }); |
There was a problem hiding this comment.
High severity vulnerability may affect your project—review required:
Line 143 lists a dependency (@modelcontextprotocol/server) with a known High severity vulnerability.
ℹ️ Why this matters
Affected versions of @modelcontextprotocol/sdk and @modelcontextprotocol/server are vulnerable to Allocation of Resources Without Limits or Throttling. McpServer places no limit on how many array elements and object keys it validates in tool-call arguments. A single unauthenticated HTTP request within the default 4 MiB body limit can exhaust the Node.js heap during validation and crash the server process (denial of service). After upgrading, also set the opt-in maxToolInputElements McpServer option and lower maxRequestBodySize.
References: GHSA
To resolve this comment:
Check if you expose the McpServer over an HTTP transport (Streamable HTTP, SSE, or createMcpHandler) rather than stdio only and it registers tools that accept input, especially arrays or records.
- If you're affected, upgrade this dependency to at least version 2.3.0 at pnpm-lock.yaml.
- If you're not affected, comment
/fp we don't use this [condition]
💬 Ignore this finding
To ignore this, reply with:
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
You can view more details on this finding in the Semgrep AppSec Platform here.
Part of #1761. Zod 4's `core`, `classic`, and `mini` entry points all re-export `locales/index.js`, which statically imports every locale. Nothing we bundle calls `z.config(z.locales.xx())`; Zod sets its English default by importing `locales/en.js` directly. A new esbuild plugin, `script/lib/zod-locales-plugin.ts`, resolves Zod's locales index to a module that exports only `en`. Error messages stay the same, and `z.locales.en` still works. The npm bundle (`script/bundle.ts`) and the standalone binary (`script/build.ts`) now use the plugin. Both inline `@sentry/mcp-core` for `sentry mcp`. The plugin lives in `script/lib/` so the `@sentry/mcp-server` bundle from #1731 can import it next to `require-alias-plugin.ts`. | | before | after | | --- | --- | --- | | CLI `dist/index.cjs` | 7,869,567 B | 7,605,958 B (−263.6 KB) | | Zod in the CLI bundle | 547,614 B | 284,024 B | | `sentry --version` max RSS | 210.4 MB | 207.6 MB | | `sentry mcp --version` max RSS | 178.0 MB | 175.0 MB | | `sentry mcp` idle max RSS (initialize + tools/list) | 180.5 MB | 177.3 MB | | `@sentry/mcp-server` bundle (#1731 branch, plugin applied locally) | 3,663,084 B | 3,399,473 B | | `sentry-mcp --version` / idle max RSS (#1731) | 137 / 143 MB | 134 / 141 MB | Byte counts come from the esbuild metafile. RSS is `process.resourceUsage().maxRSS` from a `-r` preload, on Node 22, 3 runs each. The new test bundles real Zod, ESM and CJS, with and without the plugin. It checks that the messages match and that `z.locales` has only `en`. This touches `script/bundle.ts` in two lines, an import and one entry at the top of the `plugins` array. #1762 adds code just below that array, so the two may need a trivial rebase. <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A97f516d754ebba138e04ff1efc71c075 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3A97f516d754ebba138e04ff1efc71c075/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
…1764) Part of #1761. `runMcpServer()` in `@sentry/mcp-server` imported mcp-core's server and every tool, the AI SDK providers, `@sentry/node`, and the v1 stdio transport at module load. `--help`, `--version`, and argument errors paid for all of that before printing one line. Those imports now load only after the config and token resolve, right before the server starts. The auth subcommand and the device-code flow load only on the paths that use them. Measured on Node 22, max RSS from `process.resourceUsage().maxRSS` in a `-r` preload, 3 runs each: | | before | after | | --- | --- | --- | | `sentry mcp --version` (CLI npm bundle) | 178 MB, ~450 ms | 147 MB, ~310 ms | | `sentry mcp --help` (CLI npm bundle) | 178 MB, ~435 ms | 148 MB, ~370 ms | | `sentry-mcp --version` (standalone `packages/mcp-server/dist`) | 146 MB, ~470 ms | 47 MB, ~12 ms | | `sentry mcp` idle: initialize + tools/list | 180 MB | 180 MB (unchanged) | | CLI `dist/index.cjs` bytes (metafile) | 7,869,567 | 7,870,930 (+1.3 KB of tsdown chunk glue) | The idle server still loads the same modules, so idle RSS doesn't change. **For #1731's restack:** the same issue exists in `packages/cli/src/lib/mcp.ts`. There, `startMcpServer()` imports `parseMcpInvocation` from `./mcp/server.js`, which statically imports mcp-core and `@sentry/node`. On a local copy of that branch, returning before that import for `--version` took `sentry-mcp --version` from 137 MB / 335 ms to 107 MB / 165 ms. Moving `parseMcpInvocation` into a module without those imports, next to `args.ts` and `usage.ts`, would carry this change over. This PR edits `packages/mcp-server/src/index.ts`, which #1731 deletes, so the restack can drop this file's changes. **Lazy-loading the tool modules themselves (option 3 in the issue) is left out on purpose:** `tools/list` needs every tool's schema at startup. Stubbing the whole AI SDK out of the #1731 bundle, an upper bound for lazy-loading it, saved only about 3.7 MB of idle RSS and about 30 ms. <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A97f516d754ebba138e04ff1efc71c075 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3A97f516d754ebba138e04ff1efc71c075/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
…#1765) Groundwork for #1731. The plan there is to build `@sentry/mcp-server` from the real CLI runner with a smaller route map. That build doesn't fit the size budget today, and about 1.2 MB of the overage is syntax highlighting. `buildCommand` → `formatters/output` → `human` → `markdown` imports `cli-highlight` at the top level, which brings in all of highlight.js and parse5. So every command loads it, even if it never renders a fenced code block. `formatters/highlight.ts` is now the only module that imports `cli-highlight`, and it does two things: - **Lazy at runtime.** It loads `cli-highlight` on the first code block, using the same `_require` + `REQUIRE_ALIAS_FILTER` pattern as `formatters/json`. The npm bundle and the SEA bundle still include the code, but it only runs when needed. Rendered output doesn't change. - **Can be compiled out.** A bundle that doesn't need colored code blocks sets `define: { __SENTRY_CLI_SYNTAX_HIGHLIGHT__: "false" }`. esbuild folds the guard, drops the dead `require()`, and leaves out highlight.js, parse5, and cli-highlight's copy of chalk. Code blocks then use the existing fallback color, uniform yellow, the same as an unknown language. I chose a define over aliasing the module because it's one line in any esbuild config, needs no resolver plugin, and follows the guard pattern already used for `SENTRY_CLI_VERSION` and `__SENTRY_DEBUG_ID__`. Sizes from esbuild metafiles, using `script/bundle.ts` options: | entry | default | `__SENTRY_CLI_SYNTAX_HIGHLIGHT__=false` | |---|---|---| | `src/index.ts` (full CLI) | 7,869,910 B | 6,632,859 B (−1,237,051 B) | | `lib/command.ts` graph | 5,629,790 B | 4,392,948 B | | `formatters/markdown.ts` graph | 1,303,407 B | 71,864 B | The default bundle grows by 186 B compared with `main`. On the npm bundle in a sandbox (50 interleaved runs, medians), startup dropped from 658 to 614 ms for `sentry --version`, from 718 to 664 ms for `sentry help`, and from 701 to 643 ms for `sentry org list --help`. I also checked the rest of the formatter layer for eager heavy imports. None of them is a cheap win, so this PR leaves them alone: - `human.ts` → `api-client.ts` brings in `@sentry/api` (~400 KB). The MCP server needs it anyway. - `sixel-dashboard.ts` → `sixel-image.ts` brings in `pngjs` and `jpeg-js` (~52 KB). `help.ts` → `sixel.ts` also reaches them. - `marked` is ~39 KB, and the renderer needs it. Plain output still runs the highlighter and then strips ANSI. It can't skip highlighting yet, because the stripped output doesn't always match the input byte for byte. That could be a follow-up. <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aa55a1f7d45535e774764ae30eef94190 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3Aa55a1f7d45535e774764ae30eef94190/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
Brings in the squash-merged #1763 (Zod English locale), #1764 (lazy server stack) and #1765 (lazy syntax highlighting), which this branch had merged from their PR branches. Conflicts: - packages/mcp-server/src/index.ts: kept deleted. #1764's lazy loading is already applied to the unified entry (commands/mcp.ts -> lib/mcp.ts -> lib/mcp/server.ts). - script/bundle.ts, script/build.ts: kept the zod/v3 stub plugin. bundle.ts keeps the shared script/lib/require-alias-plugin.ts (the @sentry/mcp-server bundle uses it too) instead of main's inline copy. main's filter also lists list-command.ts, but on this branch that file no longer uses _require (the route registry replaced it), so it stays out. - formatters/highlight.ts, syntax-highlight-bundle.test.ts: identical to main apart from comments that point at the shared require-alias plugin.
…945) Adds an `mcp-registry` target that publishes an MCP server's `server.json` to the [MCP Registry](https://registry.modelcontextprotocol.io). It does in Craft what getsentry/toolkit's `.github/workflows/mcp-registry.yml` does today. ```yaml targets: - name: npm - name: mcp-registry manifest: server.json # default, relative to the repository root # registryUrl: https://registry.modelcontextprotocol.io # default ``` For the release version, the target: 1. Sets `version` and every `packages[].version` in the manifest to the release version, in memory only. 2. For each `npm` package, checks that npm serves that exact version and that its `mcpName` equals the manifest `name`. When listed after `npm`, this is a short readiness check (at most 12 tries, 10s apart) to cover propagation lag, not the old 10-minute poll. 3. Looks up `/v0.1/servers/<name>/versions/<version>`. A 404 means publish. A 200 that matches the manifest (ignoring `$schema`) is a no-op success, so re-running a release is safe. A 200 that differs is an error, because registry versions are immutable. Any other status is an error. 4. Authenticates and POSTs to `/v0/publish`, then checks that the listing matches and its status is `active`. **Auth:** It calls the registry's HTTP API directly instead of downloading `mcp-publisher`. These are the same calls `mcp-publisher` makes: by default, it gets a GitHub Actions OIDC token whose audience is the registry origin (the registry checks this) and exchanges it at `/v0/auth/github-oidc`. Without OIDC, it exchanges `MCP_GITHUB_TOKEN`, the same env var `mcp-publisher` reads, at `/v0/auth/github-at`. The registry gives OIDC tokens publish access to `io.github.<repository owner>/*`. Craft's other targets already use plain `fetch`, so there's no binary to pin or verify by checksum. **Dry run:** It still runs the read-only npm and listing checks. It doesn't wait for npm, authenticate, or publish. **Follow-ups outside this repo:** - After this ships in a Craft release, toolkit can delete `.github/workflows/mcp-registry.yml` and add the target to its `packages/cli` workspace config (context: getsentry/toolkit#1731). - getsentry/publish's publish job doesn't grant `id-token: write` today. To use OIDC there, that job needs the permission. Otherwise, it needs `MCP_GITHUB_TOKEN`. Closes #944 Co-Authored-By: BYK <burak.kaya@sentry.io> <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A42059d2bd8869598da809ec3acab3646 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3A42059d2bd8869598da809ec3acab3646/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
Brings in #1762 (light `__complete` entry point). Completion now runs from the bin entry points through `lib/complete.ts`'s `runCompletion`, so the branch's `CliEntry.complete` hook and `startCli()`'s completion branch are removed; `bin.ts` keeps main's dispatch and passes `SENTRY_CLI` to `startCli()`. #1762's comment cleanup in `preloadProjectContext` is applied to `lib/project-context.ts`, where this branch moved it.
Brings in the #1766 squash (route registry). This branch already merged #1766's branch, and its final head only added main's #1763-#1765, which are here too, so every conflict (`app.ts`, `lib/help.ts`, `script/bundle.ts`) resolves to this branch's version: the application setup and `setRoutes()` live in `lib/application.ts`, help names come from `lib/app-identity.ts`, and the require-alias filter is the shared `script/lib/require-alias-plugin.ts`. The tree is unchanged.
Brings in #1770 (DB schema repair when telemetry is off). No conflicts. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`lib/help.ts` imported `sixel.ts` for its image banner, which pulled `kitty-image.ts`, `sixel-image.ts`, the generated banner image, `pngjs` and `jpeg-js` into `@sentry/mcp-server` (about 45 KB once `jpeg-js`, which mcp-core still needs, is counted out). Help now takes the banner through `setGraphicsBanner()`, and the full CLI registers sixel's renderer from `app.ts`, next to its route map. Help can only render after an app registers its routes, so the CLI shows the same banner as before; `app.ts` already loaded `sixel.ts` through the dashboard commands. The MCP server never registers it and shows the block-art banner. The bundle script now fails if `sixel.ts`, `sixel-image.ts`, `kitty-image.ts`, the banner image, or `pngjs` reach the output. `jpeg-js` stays allowed for mcp-core's snapshot and attachment tools. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
The repo-local `.sentryclirc` URL check in `serveMcp()` called `process.cwd()`, which throws ENOENT once the directory is removed (an agent's git worktree cleaned up under it), so `sentry mcp` and `@sentry/mcp-server` exited before serving. The command now passes its context's working directory, which `buildContext` already resolves with a `PWD` fallback, like every other command's lookups. Reported by Warden on #1731 (5YZ-RXX). Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Adds `mcp-server.ts` to #1762's startup guard. The entry's eager graph is 14 source modules with no `@sentry/*` SDK import, so `--version` and a lone `-v` return before `@sentry/node` or OpenTelemetry load; the guard keeps it that way. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 88c11b3. Configure here.
| /** Strip inline markdown emphasis and code markers. */ | ||
| export function renderInlineMarkdown(md: string): string { | ||
| return (md ?? "").replace(/[`*]/g, ""); | ||
| } |
There was a problem hiding this comment.
Markdown stub never wired into bundle
Low Severity
markdown-plain.ts is described as the @sentry/mcp-server stand-in for markdown.ts, but nothing aliases or imports it. Auth login and account formatters still pull the full marked renderer, so the stub is dead and the size cut it was written for never happens.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 88c11b3. Configure here.


@sentry/mcp-serverstays the recommended stdio install. Its server code moves into the CLI so it shares the CLI's auth, and the package becomes a slim, dependency-free bundle of that code (see the@sentry/mcp-serversection below). The CLI exposes the same server assentry mcp. This also locks in a one-way package graph, so MCP tools can later be built on the CLI's portable operations without a cycle.What moved where
packages/mcp-server/src/transports/stdio.ts→packages/mcp-core/src/transports/stdio.ts, exported as@sentry/mcp-core/transports/stdio. It now uses@sentry/coretracing, so mcp-core takes no Node SDK dependency.mcpis a real Stricli command (packages/cli/src/commands/mcp.ts) with its flags declared, so help is generated like every other command. Env merging and config validation live inpackages/cli/src/lib/mcp/{args,config}.ts, agent provider and telemetry setup inlib/mcp/server.ts. mcp-core stays free of CLI concepts. The command loadslib/mcp.ts, and that loads the server stack, only when it serves. The command module itself imports nothing from mcp-core (its help copies the skill names, and a test checks them againstALL_SKILLS), so docs generation andpnpm run clistill work without building mcp-core.~/.sentry/mcp.jsoncache,authsubcommands): deleted. CLI auth replaces it.@sentry/mcp-core/transports/stdio. The test client launchessentry mcpfrom CLI source. Smoke tests only target the hosted worker, so they needed no change.ensure-generated.mjsnow sends generator output to stderr, so a firstpnpm run cli mcpcannot write junk into the JSON-RPC stream.onUpstreamUnauthorizedwas dropped before. The refreshed token now reaches the context, and a regression test checks that later calls use it.npx @sentry/mcp-server@latest; the web install instructions are unchanged. User-facing docs mention the shared CLI login but do not steer installs tosentry mcp; themcp-qaskill drives the server from CLI source.docs/operations/stdio-auth.mdanddocs/releases/stdio.mdare rewritten package-first, andstdio-auth.mddocuments that each server process uses one account.Parity
@sentry/mcp-server@sentry/mcp-server(andsentry mcp)--access-token/SENTRY_ACCESS_TOKENSENTRY_AUTH_TOKEN=<token>andSENTRY_FORCE_ENV_TOKEN=1were set, through the same env-token path, so it wins over a stored login. It also replaces an existingSENTRY_AUTH_TOKEN/SENTRY_TOKEN, since the flag is the explicit choice. The flag wins over the env var. The token is sent to the--host/--urltarget as before; an org token (sntrys_) issued for another host is refused withHostScopeError. Prints one deprecation warning on stderr, without the token; the flag value is redacted from telemetry. Docs, help, andserver.jsonnow lead withSENTRY_AUTH_TOKEN(+SENTRY_FORCE_ENV_TOKEN=1, andSENTRY_HOST/SENTRY_URLfor self-hosted).~/.sentry/mcp.jsoncachesentry auth login, orSENTRY_AUTH_TOKEN/SENTRY_TOKEN), refreshed after an upstream 401. In a TTY it starts the CLI login. Over pipes it fails with an error naming the login command:npx -y @sentry/mcp-server auth loginfrom the package,sentry auth loginfromsentry mcp. The old cache is not read.--host/SENTRY_HOST,--url/SENTRY_URL--host/--url. One difference: anhttp://SENTRY_URLnow maps to--hostplus--insecure-http(the CLI's self-hosted behavior) instead of being rejected.--insecure-http--urland for sentry.io hosts.--mcp-url/MCP_URL,--sentry-dsn/SENTRY_DSN/DEFAULT_SENTRY_DSN--skills/MCP_SKILLS,--all-skills,--disable-skills/MCP_DISABLE_SKILLSseerfrom the defaults on self-hosted hosts--agent-provider/EMBEDDED_AGENT_PROVIDER,--openai-base-url,--openai-model/OPENAI_MODEL,--anthropic-base-url,--anthropic-model/ANTHROPIC_MODEL, provider API keys--organization-slug,--project-slug,--experimental--help/-h,--version/-vsentry-mcp --helplistsmcp,auth, andhelp;sentry-mcp mcp --helplists the flags and env vars. A lone-vstill prints the version; anywhere else-vis the CLI's--verbose. Changed: the output is the bare version (0.48.0), like the CLI, instead ofsentry-mcp 0.48.0.--flag=(for example--sentry-dsn=to turn off telemetry), values with a line break--flag valuefirst (splitInlineFlagValues).SENTRY_CLIENT_ID,SENTRY_MCP_AUTH_CACHEsentry-mcp auth login|logout|statusauthcommands:login(with all its flags, including--url),logout,status,list,switch,refresh,token,whoami. They use the CLI session. Account pickers take the account as an argument, since the Ink picker is not bundled.Dependency direction guard
sentry→@sentry/mcp-core→@sentry/toolkit-core, and@sentry/mcp-cloudflare→@sentry/mcp-core. No edge runs the other way.pnpm run lintenforces this with two checks:no-restricted-importsoverride banssentry,sentry/**, and relative CLI paths insidepackages/mcp-coreandpackages/toolkit-core.scripts/check-workspace-deps.mjs(lint:deps) reads every workspacepackage.json. It fails on any cycle, on mcp-core reachingsentryor mcp-cloudflare, and on toolkit-core reachingsentryor mcp-core.The rule is documented in
AGENTS.mdanddocs/architecture/overview.md#package-dependency-direction. Capabilities that only the CLI host has (SQLite cache, DSN detection from local files, file uploads) are injected into mcp-core through interfaces defined in mcp-core or toolkit-core.sentry mcpalready works this way for the access token and refresh callback inServerContext.Release and MCP registry
Every CLI release now publishes
@sentry/mcp-serverat the CLI's version, so the next one goes from 0.42.0 to the CLI's next version (0.48.0). The privatemcp-*packages keep their own versions.packages/cli/script/bump-version.tssetspackages/mcp-server/package.jsonto the CLI version on--preand to the next-devversion on--post. The bundle script fails if the two versions differ.cli-build.ymlbundles, tests, and packs the package and uploads it asmcp-server-npm-package. Thepackages/cliCraft workspace publishes it through a second npm target and attaches it to thecli@<version>GitHub release.packages/mcp-serverCraft workspace, the Release workflow'smcpoption, and the packing steps inmerge-jobs.ymlare removed.mcp-registry.ymlnow runs on stablecli@releases and strips the prefix. A manual run with-f version=Xusescli@X, or the bare tags used up to 0.42.0.mcpName: io.github.getsentry/sentry-mcpis unchanged;server.json's environment variables now declareSENTRY_AUTH_TOKEN(required, secret) andSENTRY_FORCE_ENV_TOKEN(default1) instead ofSENTRY_ACCESS_TOKEN.@sentry/mcp-serverbundle@sentry/mcp-serverstays the recommended, supported package. It ships one dependency-free file built from the CLI's own runner, so the package andsentry mcprun the same code, including self-hosted Sentry.packages/cli/src/mcp-server.tsrunscli.ts'sstartCli()withmcp-server-app.ts, a route map of the CLI'smcp(the default command),auth, andhelp. The runner takes aCliEntrythat loads the application, sosentry(sentry-cli.ts) andsentry-mcpdiffer only in their route map.lib/application.tsholds the Stricli application setup that used to sit inapp.ts.packages/mcp-server/script/bundle.tsbundles the entry intopackages/mcp-server/dist/sentry-mcp.cjs.mcp:isMcpInvocation()findsmcpafter leading global flags, or no command at all wheremcpis the default. The runner then runs Stricli without the CLI's telemetry, recovery middleware, and update check (the server owns stdout and has its own telemetry). The command resolves when the client closes stdin, and only then does the runner close the dispatcher and arm the force-exit backstop.lib/app-identity.tsreplaceslogin-command.tsandusage.ts. Each entry registers its name, and hints (AuthError, refresh and device-flow failures, host-scope errors) and help examples use it:sentry auth login,sentry-mcp auth login, ornpx -y @sentry/mcp-server auth loginwhen npx launched the process (npm_command=execor an_npxpath). MCP telemetry keepsapp.server.distributionatsentry mcpor@sentry/mcp-server.--help,--version, andauth …do not load mcp-core's server, the provider factory, the MCP telemetry, or the stdio transport;commands/mcp.tsimportslib/mcp.tsonly when it serves, andlib/mcp.tsimportslib/mcp/server.tsonly after setup checks pass. A bare--version(or lone-v) returns before the application loads.--helpandauthstill load@sentry/node, because the CLI's command builder and error reporting import it, same assentry --help.261e371f, separate commit): stdio uses@modelcontextprotocol/serverand its stdio transport, like the Cloudflare worker.startStdio()returns aclosedpromise; v2's transport closes when stdin ends, which is what lets the command return.c0243b5athen removes SDK v1 from mcp-core:buildServer()always builds a v2McpServer, thesdkVersionoption is gone, and@modelcontextprotocol/sdkis only a dev dependency of mcp-core (its tests use the in-memory client). The Cloudflare worker keeps its own SDK dependency forStreamableHTTPClientTransport. Bothsentry mcpand the bundle serve 14 tools over v2 and exit 0 within ~13–16 ms of stdin closing.__SENTRY_CLI_SYNTAX_HIGHLIGHT__=false(perf(cli): Load syntax highlighting lazily and allow compiling it out #1765) and a new__SENTRY_CLI_INK_UI__=false(lib/select-prompt.ts) compile out highlight.js/parse5 and Ink;zod/v3resolves to a shared stub (packages/cli/script/lib/zod-v3-stub-plugin.ts) in both this bundle and the CLI's (script/bundle.ts,script/build.ts):@ai-sdk/provider-utilsand@mastra/schema-compatonly reach it for Zod 3 inputs, and nothing we bundle builds Zod 3 schemas. The stub keepsZodTypea class so Mastra'sinstanceofcheck is false, and throws a clear error if a Zod 3 path ever runs. A test bundles the real Mastra client and provider-utils, runs a workflow create/start, and converts Zod 4 and JSON schemas. With SDK v1 gone from mcp-core, the bundle no longer needs a v1 stub and fails if any@modelcontextprotocol/sdkmodule reaches it.sentry init, and build/sourcemap/debug-file code. The SQLite WASM fallback is also left out, so the engine moves from>=22.13to>=22.15(nativenode:sqlite), and the bin exits early with a clear error on older Node.js.@modelcontextprotocol/sdkmodule) contributes code to the output, or if the file grows past 3.75 MiB (MAX_BUNDLE_BYTES, ~240 KB over the measured size; left as is, since removing SDK v1 saved only ~1 KB here, where it was already stubbed).packages/mcp-server/test/bundle.test.mjsruns the built file:initializeplustools/listover stdio with--sentry-dsn=(withSENTRY_AUTH_TOKEN, and with the deprecated--access-token, checking the warning is on stderr once and never echoes the token), exit on stdin close, no runtime dependencies, bare--versionand-v,--helplisting exactlymcp/auth/help,mcp --helpexamples namingsentry-mcp, the login hint with and without npx,auth status, and rejecting other CLI commands.cli-build.ymlbundles, tests, and packs the package next to the CLI's npm package.The old
@sentry/mcp-server/transports/stdioexport is gone (now@sentry/mcp-core/transports/stdio), and the standalone clean-consumer workflow (mcp-server-package.yml) is removed; the bundle test replaces it.Release note: do not run
npm deprecate. Users on Node.js 22.13 or 22.14 need to upgrade Node.js.Measurements (Node 22, this sandbox; startup rows are the median of 7 runs, idle RSS is 5 runs)
53fc92fe)9977bb0ca98cb249; 3,689,513 B at0a864625)sentry-mcp --versionsentry-mcp --helpsentry-mcp auth status(logged out)initialize+tools/list--help,auth status, and idle RSS were measured at7a2f0a2a; the two later commits only add the-vfast path and move a string list, and the bundle grew 89 bytes.CLI
dist/index.cjs: 7,426,174 B beforec0243b5a→ 7,203,971 B without SDK v1 (−222 KB; ajv and most of zod-to-json-schema go with it) → 7,142,739 B with thezod/v3stub (−61 KB) → 7,143,333 B ata98cb249→ 7,021,265 B at0a864625(#1762 moves the__completepath into a separate 331,140 Bdist/complete.cjs).The bundle ends up about the same size as before even with
550 KB of savings (Zod locales −264 KB, SDK v1 and Zod 3 −280 KB), because it now carries the CLI runner, the fullauthcommands, and generated help. Largest inputs:@sentry/api482 KB,@modelcontextprotocol/server291 KB (156 KB of it ajv),@sentry/server-utils242 KB,zod193 KB, mcp-core's OTel semantics 187 KB,@sentry/core162 KB.mcp-core CJS output
Nothing builds or consumes mcp-core CJS anymore. #1732, now merged into this branch from main, switched
packages/mcp-core/tsdown.config.tstoformat: ["esm"]. mcp-core is"type": "module", and everyexportsentry maps onlytypesanddefault(.js) with norequirecondition. The CLI's esbuild bundle (CJS output) resolvesdefaultand converts the ESM itself, andscripts/check-build-imports.tsnow checksdist/server.js. This PR does not touch the build format.Verification
pnpm run tsc,pnpm run lint(includeslint:deps), and CLIci:policypass.pnpm run test: toolkit-core, mcp-core, mcp-cloudflare, mcp-test-client, docs-mcp, local, and cli-docs pass. CLI: 12,807 pass; the 6 failures are chmod-based tests (completionsEACCES/EPERM, read-only DB repair, upgrade lock permissions, unreadable DSN file, file-changes I/O) that fail in this sandbox's filesystem and do not touch this diff. The MCP, auth, app-identity, startup, help, and completion suites pass.pnpm --filter sentry run generate:docspasses withpackages/mcp-core/distremoved, which is thesentry-cli-docsCI condition.test/lib/mcp/args.test.tsparses with the command's real Stricli parameters (test/lib/mcp/parse-flags.ts);mcp-start.test.tsandmcp-auth.test.tsdriveserveMcp()andwithConfiguredTarget()through it;mcp-command.test.tscoversisMcpInvocation, the{mcp, auth, help}app, no CLI telemetry formcp, teardown only after the server returns, setup failures,--help, the help's skill list againstALL_SKILLS, and unknown flags;app-identity.test.tscovers names and npx hints.usage*.test.ts,mcp/auth.test.ts, andmcp-run.test.tsare deleted with their modules.pnpm --filter @sentry/mcp-server run bundle(withSENTRY_AUTH_TOKENunset) builds 3,689,513 B at0a864625(242,647 B under the 3.75 MiB limit);test:bundlepasses 13/13.node dist/bin.cjs mcpanswerstools/listwith 14 tools over SDK v2 and exits 0 when stdin closes. With--access-token, stdout carries only JSON-RPC frames and stderr has the one deprecation line, without the token. CLItest/e2e/bundle.test.ts+library.test.tspass 26/26.a98cb249:pnpm run lintpasses;tscpasses for cli, mcp-core, mcp-cloudflare, mcp-server-evals, and mcp-test-client; mcp-core (1,890), mcp-cloudflare (443), and mcp-test-client (82) tests pass. CLItest/lib test/commands test/types test/script: 12,816 pass, 11 fail, and all 11 fail the same way without this change (6 chmod-based tests, plus 5 login-hint wording tests inerrors,oauth, andauto-login-host-guardthat seenpx -y sentrybecause the sandbox runs vitest through npx).main(0a864625;5a72e8a3has the same tree):pnpm run lintandpnpm run tscpass. CLItest/script, completion, db, logger, telemetry, MCP, app-identity, and startup suites: 1,237 pass; the 3 failures are the sandbox-only chmod/read-only tests above (completionsEACCES/EPERM, read-only DB repair). Both bundles build withSENTRY_AUTH_TOKENunset:sentry-mcp.cjs3,689,513 B with no highlight.js in the output, CLIdist/index.cjs7,021,265 B plusdist/complete.cjs331,140 B. CLItest/e2e/bundle.test.ts+library.test.tspass 27/27, including perf(cli): Give__completeits own light entry point #1762's check that__completenever loadsindex.cjs.--access-tokentests (mcp-start.test.ts): it serves the same token and refresh result asSENTRY_AUTH_TOKEN+SENTRY_FORCE_ENV_TOKEN=1, overrides a stored login before and after startup, overridesSENTRY_AUTH_TOKEN/SENTRY_TOKEN, leavesprocess.envuntouched, prints the hint once to stderr and nothing to stdout, and keeps the token out of the hint and ofMalformedAuthTokenError/HostScopeError. The existing self-hosted, org-token, and.sentryclirccases still pass.craft config --workspace packages/cliand the release checks above are unchanged from the earlier verification.Noticed, not changed:
serverInfo.versionininitializereports mcp-core's package version (0.42.0), as it did before this PR, not the CLI/package version.--
View Session in Sentry