Skip to content

fix(mcp): Report the shipped version in stdio serverInfo and User-Agent - #1994

Merged
BYK merged 6 commits into
mainfrom
fix/stdio-server-version
Nov 5, 2026
Merged

BYK merged 6 commits into
mainfrom
fix/stdio-server-version

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

On stdio, @sentry/mcp-server reported mcp-core's version (0.42.0) instead of its own version, which is the CLI version (0.48.0-dev.0 on main). The wrong value showed up in four places:

  • initialize → serverInfo.version
  • the stdio span's app.server.version and service.version
  • the get_sentry_mcp_info tool
  • the User-Agent on Sentry API, docs, and LLM provider requests

All four read mcp-core's LIB_VERSION, which tsdown bakes in from mcp-core's own package.json.

version.ts now has a process-wide setServerVersion(). getServerVersion() and getUserAgent() read it and fall back to LIB_VERSION. The CLI calls it with CLI_VERSION at stdio startup, next to the existing process-wide agent provider settings. All four surfaces read that one value, and mcp-core still never imports the CLI.

The embedded agent's User-Agent is now set on the generateText call. generateText sets its own call-level user-agent, which replaced the provider-level header, so sentry-mcp/... never reached the LLM provider. The AI SDK now appends its own tokens after ours.

Cloudflare never calls the setter, so it keeps reporting 0.42.0. That's mcp-cloudflare's own package version, so it's correct.

Why process-wide and not on ServerContext: an earlier revision put the version on ServerContext. That can't reach the User-Agent, because the API client, the docs fetch, and the LLM providers are all built without the context. There's one version per process in both hosts, so one setter covers every surface and nothing needs threading.

Verification:

  • I built the bundle and talked to it over stdio. initialize reports 0.48.0-dev.0 (it was 0.42.0).
  • packages/mcp-server/test/bundle.test.mjs asserts that serverInfo.version equals the package version.
  • The same file also calls whoami against a local Sentry stub and asserts the request's User-Agent is sentry-mcp/<package version> (https://mcp.sentry.dev). With the CLI's setServerVersion call removed, both checks fail with 0.42.0. They stop proving anything if mcp-core and the CLI ever ship the same version.
  • Unit tests cover:
    • the serverInfo version and its fallback
    • get_sentry_mcp_info
    • the stdio span attributes
    • the API client's User-Agent
    • the User-Agent an embedded agent call sends to a real OpenAI provider

Review history:

  • The first reviewer passed 54215cf.
  • The second reviewer passed 2f4681c.
  • d32e146 (co-authored by BYK) put the LLM User-Agent on the generateText call and removed it from the providers. 10d3362 added the bundle User-Agent assertion.
  • Review of d32e146 found a must-fix after this PR merged. The chat playground calls streamText with getOpenRouterModel() directly, and streamText adds no call-level user-agent, so playground requests lost the sentry-mcp/... User-Agent. That regression is on main.
  • Follow-up, not part of this PR: commit 9885b7b on branch fix/streamtext-user-agent fixes it. It puts the provider-level User-Agent back on all four providers and keeps the call-level header. It also adds a streamText test and tidies the bundle test's stderr and JSON handling. Its review is pending, and it doesn't have a PR yet.

Checks at the merged head (10d3362): all scoped to the affected packages.

  • Typecheck passes for mcp-core, cli, and mcp-cloudflare.
  • mcp-core tests pass (2096), as do the CLI MCP tests (191) and the mcp-server bundle tests (17).
  • Root pnpm run lint passes.
  • The follow-up branch passes 2097 mcp-core tests and 17 bundle tests.
  • I skipped root pnpm run tsc/pnpm run test: they build mcp-cloudflare, which uploads source maps.

via @dcramer, @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 5, 2026 18:48
@sentry/mcp-server ships at the CLI version (0.48.0-dev.0 on main),
but serverInfo.version came from mcp-core's LIB_VERSION, which tsdown
bakes from mcp-core's own package.json (0.42.0). The stdio span's
service.version and get_sentry_mcp_info drifted the same way.

Add an optional ServerContext.serverVersion that buildServer,
startStdio, and get_sentry_mcp_info report, falling back to
LIB_VERSION. The CLI sets it to CLI_VERSION. Cloudflare leaves it unset
and keeps reporting 0.42.0, which matches mcp-cloudflare's version.

Co-Authored-By: David Cramer <[email protected]>
Assert that the bundled @sentry/mcp-server reports its package version
in serverInfo, so dropping the CLI's serverVersion fails the bundle
test. Cover the stdio span's version attributes too.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 5, 2026 7:28pm UTC

Request Review

@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 5, 2026
Comment thread packages/mcp-core/src/server.ts Outdated
Comment on lines 299 to 305
const server = new McpServer(
{
...MCP_SERVER_INFO,
version: LIB_VERSION,
version: getServerVersion(context),
},
{ maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS },
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High severity vulnerability may affect your project—review required:
Line 299 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.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fixed, follow-up: the stdio User-Agent (sentry-mcp/<LIB_VERSION>) still reports mcp-core's version. USER_AGENT is a module-level constant passed through the API client and the agent providers, so moving it onto the context is a separate change. The Sentry release was already right, because the CLI sets release: CLI_VERSION.

Fix this too.

The stdio User-Agent still said sentry-mcp/0.42.0, because USER_AGENT
was a module constant built from mcp-core's LIB_VERSION and read by the
API client, the docs fetch, and the LLM providers, none of which see the
server context.

Replace ServerContext.serverVersion with a process-wide
setServerVersion(), which the CLI calls at startup next to the agent
provider settings. serverInfo, stdio telemetry, get_sentry_mcp_info, and
getUserAgent() all read getServerVersion(), so every surface reports one
version. Cloudflare never calls it and keeps LIB_VERSION.
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Nov 5, 2026
generateText sets a call-level user-agent (ai/<version>) and the
provider merges call headers over its own, so the sentry-mcp
User-Agent configured on each provider never reached the wire. Pass it
as a generateText call header instead, where the SDK keeps it and
appends its own tokens, and drop the dead provider-level headers.

Co-Authored-By: BYK <[email protected]>
Call whoami against a local Sentry stub and check the User-Agent, so a
bundle that ends up with two copies of mcp-core's version module fails.
Reset the server version in afterEach in get_sentry_mcp_info's test, to
match the other version tests.
@BYK
BYK enabled auto-merge (squash) November 5, 2026 19:29
@BYK
BYK merged commit 8e96f40 into main Nov 5, 2026
31 checks passed
@BYK
BYK deleted the fix/stdio-server-version branch November 5, 2026 19:39
@sentry-junior
sentry-junior Bot restored the fix/stdio-server-version branch November 5, 2026 19:41
@sentry-junior sentry-junior Bot changed the title fix(mcp): Report the shipped version in stdio serverInfo fix(mcp): Report the shipped version in stdio serverInfo and User-Agent Nov 5, 2026

This branch was previously deployed

2 inactive deployments
Actions — 10d33629 Deployed Nov 5, 2026 by sentry-junior[bot] via eval #1593
Preview — 10d33629 Deployed Nov 5, 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.

2 participants