Skip to content

feat(mcp): Keep get_sentry_resource loaded in Claude Code - #1989

Open
sentry-junior[bot] wants to merge 2 commits into
mainfrom
feat/mcp-always-load-resource
Open

sentry-junior[bot] wants to merge 2 commits into
mainfrom
feat/mcp-always-load-resource

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Summary

Claude Code hides MCP tools behind tool search unless a tool sets _meta["anthropic/alwaysLoad"]. docs/mcp/harnesses.md already named get_sentry_resource as the tool to keep loaded, but none of our tools sent _meta.

  • ToolConfig gets an optional _meta field, which buildServer passes to registerTool.
  • get_sentry_resource is the only tool that sets {"anthropic/alwaysLoad": true}. A pasted Sentry URL then works without a tool search first. The key follows the current Claude Code docs ("Mark a tool to load upfront or stay deferred").
  • harnesses.md now says we set it. A user's server-level alwaysLoad setting can still override it.
  • measure-tokens now includes _meta, so its count matches the wire.

Impact

  • This only changes behavior in Claude Code. Other clients ignore the key.
  • Token cost: +11 against current main, which now includes the feat(mcp): Add a display title to every tool #1991 titles (47,553 → 47,564).
  • server.all-tools.test.ts checks that get_sentry_resource is the only tool in tools/list with _meta.

Checks: package-scoped tsc for @sentry/mcp-core and @sentry/mcp-cloudflare, root lint, and the mcp-core and mcp-cloudflare test suites. After rebasing onto main (with #1991), I re-ran mcp-core tsc, check:generated, root lint and the mcp-core tests. I didn't run the root tsc or test scripts, because they run the cloudflare build, which uploads source maps to Sentry.

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 5, 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 5, 2026 7:20pm UTC

Request Review

Claude Code defers MCP tools behind tool search unless a tool sets
`_meta["anthropic/alwaysLoad"]`. harnesses.md named get_sentry_resource
as the tool to keep loaded, but no tool sent `_meta`.

Add an optional `_meta` field to ToolConfig, pass it to registerTool,
and set `anthropic/alwaysLoad` on get_sentry_resource only. A test
checks that tools/list exports it on that tool and no other.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Resolve the ToolConfig conflict with #2035: keep the _meta field and the
outputSchema-typed handler.
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Nov 5, 2026
@mehanig

mehanig commented Nov 6, 2026

Copy link
Copy Markdown

@getsentry-bot It looks like it's added to all clients? Can server not sent this field if User-Agent is not claude-code or maybe by looking at params.ClientInfo.name durin init event ?

This branch was successfully deployed

1 active (outdated) and 1 inactive deployments
Actions — 58fb913c Deployed Nov 5, 2026 by sentry-junior[bot] via eval #1682
Preview — cd23ede0 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