Repository navigation
feat(mcp-server): Ship @sentry/mcp-server as a slim bundle that shares CLI auth - #1731
Open
sentry-junior[bot] wants to merge 12 commits into
Open
sentry-junior[bot] wants to merge 12 commits into
sentry-junior[bot] wants to merge 12 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.
|
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>
Contributor
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 982a007. Configure here.
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.
Restore the web install instructions, the MCP registry manifest, and its publish workflow to @sentry/mcp-server, and move mcpName back to that package. Docs and READMEs recommend npx @sentry/mcp-server@latest and mention sentry mcp as the same server. Co-Authored-By: BYK <burak.kaya@sentry.io>
sentry-junior Bot
added a commit
that referenced
this pull request
Oct 29, 2026
#1731 now leaves server.json and the recommended stdio install on @sentry/mcp-server, with sentry mcp as the same server for CLI users. Co-Authored-By: BYK <burak.kaya@sentry.io>
Auth errors in the standalone bundle told users to run 'sentry auth login', which needs the full CLI. A shared login-command constant now names 'npx -y @sentry/mcp-server auth login' when running as the bundle and 'sentry auth login' otherwise. Hints that confirm a self-hosted host with --url still name the CLI, because the standalone auth login takes no flags. Co-Authored-By: BYK <burak.kaya@sentry.io>
…unt per server Co-Authored-By: BYK <burak.kaya@sentry.io>
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.

@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.runMcpServer): moved topackages/cli/src/lib/mcp/{args,config,usage,server}.ts. mcp-core stays free of CLI concepts.lib/mcp.tsstill loads the host with a dynamic import, so normal CLI startup does not pay for mcp-core or Zod.~/.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_TOKENsntrys_) issued for another host is refused withHostScopeError. Other CLI commands ignoreSENTRY_ACCESS_TOKEN.~/.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/-v--versionprintssentry mcp <cli version>(sentry-mcp <package version>from@sentry/mcp-server).SENTRY_CLIENT_ID,SENTRY_MCP_AUTH_CACHEsentry-mcp auth login|logout|statussentry-mcp auth loginruns the CLI device flow with plain-text output and stores the CLI session.logoutandstatuspoint tonpx -y sentry auth ..., which reads the same session.sentry mcp authpoints users atsentry auth.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.MCP registry
Unchanged.
server.jsonandmcp-registry.ymlkeep the listing on@sentry/mcp-server, which keepsmcpName: io.github.getsentry/sentry-mcp.@sentry/mcp-serverbundle@sentry/mcp-serverstays the recommended, supported package. It now ships the CLI's server code bundled into one dependency-free file, instead of its own copy of the server. One implementation serves the package andsentry mcp, including self-hosted Sentry.packages/cli/src/mcp-server.tsis the entry point.packages/cli/script/bundle-mcp-server.tsbundles it intopackages/mcp-server/dist/sentry-mcp.cjs(about 3.6 MB, about 0.95 MB packed). The package has no runtime dependencies, and thesentry-mcpbin name is unchanged.sentry mcpand the bundle both calllib/mcp/run.ts(runMcpServer) andlib/project-context.ts(preloadProjectContext, moved out ofcli.ts).lib/suppress-sqlite-warning.tsreplaces the inline warning filter inbin.ts.startMcpServerreports whether a server is running, sorunMcpServercloses the network dispatcher and schedules the force-exit backstop after--help,--version, or a setup error (and the standaloneauthentry does the same), but never under a live server.--help/--versionnamesentry-mcpwhen the bundle definesSENTRY_MCP_SERVER_VERSION, andlib/login-command.tsmakes auth hints (AuthError, refresh and device-flow failures) namenpx -y @sentry/mcp-server auth loginin the bundle. Hints that confirm a self-hosted host with--urlstill namenpx -y sentry auth login --url, since the standaloneauth logintakes no flags.sentry-mcp auth login(lib/mcp/auth.ts) runs the CLI's device flow. The bundle swapsformatters/markdown.tsformarkdown-plain.ts, so login output is plain text and the markdown renderer and syntax highlighter stay out.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.packages/mcp-server/test/bundle.test.mjsruns the built file:initializeplustools/listover stdio, no runtime dependencies inpackage.json,--version/--help, theauthsubcommands, and the login hint when no credentials are available.merge-jobs.ymlbundles, tests, and packs the 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:
@sentry/mcp-servercan publish fromrelease/mcpbranches through its Craft workspace as before. Do not runnpm deprecate. Users on Node.js 22.13 or 22.14 need to upgrade Node.js.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 lint(includeslint:deps), CLItsc --noEmit,ci:policy,docs:check, andcheck:generatedpass.pnpm --filter @sentry/mcp-server run bundlebuilds 3555 KB;test:bundlepasses 6/6.npm installof the packed tarball installs one package;sentry-mcpanswerstools/listwith 14 tools on sentry.io and 13 with--host=sentry.example.com(Seer is off on self-hosted). No SQLite warning reaches stderr.agent-skillsimport to the entry point fails the bundle with the guard error.sentry mcpanswerstools/list.Codemod used for stale package paths in contributor docs
sed -i 's#packages/mcp-server/src/#packages/mcp-core/src/#g' \ docs/contributing/api-patterns.md docs/operations/{logging,monitoring,security}.md docs/testing/overview.mdvia BYK.
--
View Session in Sentry