Repository navigation
fix(mcp): Report the shipped version in stdio serverInfo and User-Agent - #1994
Conversation
@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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
# Conflicts: # packages/mcp-core/src/server.ts
| const server = new McpServer( | ||
| { | ||
| ...MCP_SERVER_INFO, | ||
| version: LIB_VERSION, | ||
| version: getServerVersion(context), | ||
| }, | ||
| { maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS }, | ||
| ); |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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.
On stdio,
@sentry/mcp-serverreported mcp-core's version (0.42.0) instead of its own version, which is the CLI version (0.48.0-dev.0on main). The wrong value showed up in four places:initialize→serverInfo.versionapp.server.versionandservice.versionget_sentry_mcp_infotoolUser-Agenton Sentry API, docs, and LLM provider requestsAll four read mcp-core's
LIB_VERSION, which tsdown bakes in from mcp-core's ownpackage.json.version.tsnow has a process-widesetServerVersion().getServerVersion()andgetUserAgent()read it and fall back toLIB_VERSION. The CLI calls it withCLI_VERSIONat 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-Agentis now set on thegenerateTextcall.generateTextsets its own call-leveluser-agent, which replaced the provider-level header, sosentry-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 onServerContext. 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:
initializereports0.48.0-dev.0(it was0.42.0).packages/mcp-server/test/bundle.test.mjsasserts thatserverInfo.versionequals the package version.whoamiagainst a local Sentry stub and asserts the request'sUser-Agentissentry-mcp/<package version> (https://mcp.sentry.dev). With the CLI'ssetServerVersioncall removed, both checks fail with0.42.0. They stop proving anything if mcp-core and the CLI ever ship the same version.get_sentry_mcp_infoUser-AgentUser-Agentan embedded agent call sends to a real OpenAI providerReview history:
54215cf.2f4681c.d32e146(co-authored by BYK) put the LLMUser-Agenton thegenerateTextcall and removed it from the providers.10d3362added the bundle User-Agent assertion.d32e146found a must-fix after this PR merged. The chat playground callsstreamTextwithgetOpenRouterModel()directly, andstreamTextadds no call-level user-agent, so playground requests lost thesentry-mcp/...User-Agent. That regression is on main.9885b7bon branchfix/streamtext-user-agentfixes it. It puts the provider-level User-Agent back on all four providers and keeps the call-level header. It also adds astreamTexttest 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.pnpm run lintpasses.pnpm run tsc/pnpm run test: they build mcp-cloudflare, which uploads source maps.via @dcramer, @BYK.
--
View Session [Sentry]