Skip to content

ref(mcp): Always send MCP telemetry to the CLI's project - #1969

Merged
BYK merged 1 commit into
mainfrom
junior/mcp-remove-dsn-override
Nov 4, 2026
Merged

BYK merged 1 commit into
mainfrom
junior/mcp-remove-dsn-override

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Summary

Remove every way to override the DSN for the server's own telemetry in sentry mcp and @sentry/mcp-server:

  • the --sentry-dsn flag;
  • the SENTRY_DSN and DEFAULT_SENTRY_DSN env reads;
  • the sentryDsn config plumbing.

MCP telemetry now always goes to SENTRY_CLI_DSN. Only the CLI's telemetry opt-outs decide whether it's on.

SENTRY_DSN is the variable people set for their own apps. An MCP server started from a project shell or IDE inherited it and sent our telemetry to the user's own Sentry project.

The override dates back to #120 (Apr 2025), which added Sentry to the original stdio package with --sentry-dsn/SENTRY_DSN. In that design, an empty --sentry-dsn= was the documented opt-out. #1401 (sentry mcp) and #1731 (the slim @sentry/mcp-server bundle) carried it over.

Key changes

  • packages/cli/src/lib/mcp/:
    • args.ts drops the flag type, the env reads and the merge.
    • config.ts drops sentryDsn.
    • server.ts always calls init({ dsn: SENTRY_CLI_DSN, enabled: isTelemetryEnabled() }).
    • The early return for an empty --sentry-dsn= is gone, and so is the rule that an explicit DSN ignored the CLI opt-out.
  • commands/mcp.ts: the --sentry-dsn flag and the SENTRY_DSN help line are removed. The skill reference is regenerated with generate:skill.
  • mcp-test-client: stops passing --sentry-dsn and SENTRY_DSN to the server it launches. Its own --sentry-dsn, for the test client's own Sentry client, stays, with a clearer description.
  • mcp-core/tsdown.config.ts: drops the unused DEFAULT_SENTRY_DSN define. Nothing in mcp-core reads it; it was the old stdio package's build-time DSN.
  • Docs: docs/operations/monitoring.md, docs/testing/stdio.md, TELEMETRY.md, the mcp-core README and the stdio setup page now point to the opt-out instead.
  • The remote/Cloudflare VITE_SENTRY_DSN is unchanged. That's deployment config, not a user override.

Breaking changes

For @sentry/mcp-server and sentry mcp users:

  • --sentry-dsn is now an unknown flag. A config that passes it, including the documented opt-out --sentry-dsn=, fails before the server starts. I checked on the rebuilt bundle (node dist/sentry-mcp.cjs --sentry-dsn= and --sentry-dsn=https://…): stderr shows No flag registered for --sentry-dsn and the exit code is 252.
    • An error is safer than silently ignoring the flag. Ignoring it would quietly turn telemetry back on for anyone who had opted out.
  • SENTRY_DSN and DEFAULT_SENTRY_DSN are silently ignored. Anyone who used them to send MCP telemetry to their own Sentry instance now reports to the Sentry CLI's project instead.

Migration: remove --sentry-dsn from the MCP config. To turn telemetry off, set SENTRY_CLI_NO_TELEMETRY=1 or DO_NOT_TRACK=1 in the server's env, or run sentry cli defaults telemetry off once (shared config dir).

{ "command": "npx", "args": ["@sentry/mcp-server@latest"], "env": { "SENTRY_CLI_NO_TELEMETRY": "1" } }

computeTelemetryEffective() in packages/cli/src/lib/telemetry.ts checks the env vars for an exact "1", then the stored preference.

Release note: the title has no !. .craft.yml uses changelog.policy: auto and versioning.policy: auto, there's no .github/release.yml, and Craft's default categories map type!: to a major bump. A ! would most likely cut CLI 1.0.0 (inferred from Craft's docs, not tried). docs/releases/stdio.md has no separate breaking-change process for @sentry/mcp-server, which ships at the CLI's version. Please call out the break in the release notes, or add ! if a major bump is intended.

Tests

  • test/lib/mcp/telemetry.test.ts:
    • init always uses SENTRY_CLI_DSN;
    • SENTRY_CLI_NO_TELEMETRY=1 and DO_NOT_TRACK=1 each disable it;
    • with SENTRY_DSN and DEFAULT_SENTRY_DSN set in the env, the DSN is still the CLI's (the env leak behind this change).
  • test/lib/mcp/args.test.ts: parseMcpEnv ignores both env vars, and --sentry-dsn= is rejected.
  • packages/mcp-server/test/bundle.test.mjs:
    • the bundle refuses --sentry-dsn=;
    • the "telemetry on" exit test turns telemetry on with SENTRY_CLI_NO_TELEMETRY=0 and sends it to a dead https_proxy, so nothing leaves the machine.

Screenshot

The stdio setup page (packages/mcp-cloudflare, ?transport=stdio), from a local vite build:

stdio setup configuration

Interaction with #1963

#1963 stacks the offline telemetry store on #1960. It gates the store in mcp/server.ts on useCliDsn, which is true only without an override. Once this merges, that gate is always true and becomes dead code. Whichever PR lands second removes it and always uses the store.

via @BYK.

--

View Session in Sentry

Remove the --sentry-dsn flag and the SENTRY_DSN/DEFAULT_SENTRY_DSN
reads from `sentry mcp` and @sentry/mcp-server. An MCP server started
from a project shell or IDE inherited the app's SENTRY_DSN and sent its
telemetry to the user's own Sentry project. Telemetry now always goes to
SENTRY_CLI_DSN, and only the CLI's opt-outs (SENTRY_CLI_NO_TELEMETRY=1,
DO_NOT_TRACK=1, `sentry cli defaults telemetry off`) turn it off.

Breaking: --sentry-dsn is now an unknown flag, so a config that passes
it fails to start.

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

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 4, 2026 10:51pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 4, 2026 23:01
@BYK
BYK merged commit 00eca2d into main Nov 4, 2026
39 checks passed
@BYK
BYK deleted the junior/mcp-remove-dsn-override branch November 4, 2026 23:02
sentry-junior Bot added a commit that referenced this pull request Nov 4, 2026
The DSN override that kept `sentry mcp` off the store is being removed
(#1969), so drop the `useCliDsn` gate: the store follows the CLI's
telemetry opt-out alone. The new lines stay clear of the DSN lines
#1969 rewrites.

Refs #1956
sentry-junior Bot added a commit that referenced this pull request Nov 4, 2026
The DSN override that kept `sentry mcp` off the store is being removed
(#1969), so drop the `useCliDsn` gate: the store follows the CLI's
telemetry opt-out alone. The new lines stay clear of the DSN lines

Refs #1956
sentry-junior Bot added a commit that referenced this pull request Nov 4, 2026
The DSN override that kept `sentry mcp` off the store is being removed
(#1969), so drop the `useCliDsn` gate: the store follows the CLI's
telemetry opt-out alone. The new lines stay clear of the DSN lines

Refs #1956
sentry-junior Bot added a commit that referenced this pull request Nov 4, 2026
The DSN override that kept `sentry mcp` off the store is being removed
(#1969), so drop the `useCliDsn` gate: the store follows the CLI's
telemetry opt-out alone. The new lines stay clear of the DSN lines

Refs #1956

This branch was successfully deployed

1 active deployment
Preview — b94b9111 Deployed Nov 4, 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