Skip to content

feat(mcp): Add a fresh input to read tools that bypasses cached reads - #1832

Merged
BYK merged 1 commit into
mainfrom
feat/mcp-fresh-read-input
Nov 3, 2026
Merged

BYK merged 1 commit into
mainfrom
feat/mcp-fresh-read-input

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Task 6.3 of #1669, on top of the transport's fresh() callback from #1720.

What changes

  • ParamFresh in mcp-core/src/schema.ts: fresh?: boolean, described as "Bypass cached reads." The description is kept short because every read tool's schema carries it.
  • internal/fresh-reads.ts: withFreshReadInput(tool) adds the input and wraps the handler. With fresh: true, the handler runs inside an AsyncLocalStorage scope, and it never sees fresh in its params. isFreshRead() reads that scope.
  • tools/catalog/index.ts applies the wrapper to every catalog tool that has readOnlyHint: true and openWorldHint: true, except search_docs and get_doc, which read docs.sentry.io rather than the Sentry API. The wrapper sits on the tool itself, so direct calls and execute_sentry_tool both get it. No tool file or execute_sentry_tool changes.
  • SentryApiService's transport passes fresh: isFreshRead, so the shared client sees the scope only through the callback. Shared code still has no AsyncLocalStorage.
  • docs/contributing/adding-tools.md explains the rule. Tool definitions are regenerated.

Behavior today: none visible. The MCP transport has no cache store yet (that's 7.x), so fresh has nothing to bypass until one is wired in. This PR makes the input and the scope ready for that.

Token cost (pnpm run measure-tokens): 9,014 → 9,144 (+130, +1.4%). Of the 14 direct tools, 10 gain the input at 13 tokens each: find_organizations, find_projects, search_issues, get_sentry_resource, and the six search_* tools.

Checks (all run with SENTRY_AUTH_TOKEN unset)

  • pnpm run tsc, pnpm run lint and docs:check pass.
  • mcp-core: 1930 passed, 6 skipped. The new fresh-reads.test.ts covers the scope being set only when fresh: true, the scope surviving an await, fresh being stripped from handler params, a non-boolean being rejected, and which catalog tools get the input. server.test.ts adds fresh to the get_replay_details schema keys it expects.
  • mcp-cloudflare: 447 passed. mcp-server bundle tests: 15 passed.

Other in-flight work on execute_sentry_tool, get_sentry_resource, find_dropped_events and get_alert_rule doesn't touch these files. Expect only a toolDefinitions.json regeneration on rebase.

via @BYK.

--

View Session [Sentry]

Every catalog tool with readOnlyHint and openWorldHint, except the docs
tools, gets the shared ParamFresh input. A call with fresh: true runs the
handler in an AsyncLocalStorage scope, and SentryApiService's transport
reads that scope through its fresh() callback (#1720).

Task 6.3 of #1669.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 3, 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 3, 2026 12:24am UTC

Request Review

@BYK
BYK merged commit 7216425 into main Nov 3, 2026
46 of 48 checks passed
@BYK
BYK deleted the feat/mcp-fresh-read-input branch November 3, 2026 10:56

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 43494f2b Deployed Nov 3, 2026 by vercel[bot]
Actions — 43494f2b Deployed Nov 3, 2026 by sentry-junior[bot] via eval #1502
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