Skip to content

fix(mcp): Add dataset-specific hints for common rejected event fields - #1679

Merged
BYK merged 1 commit into
mainfrom
fix/mcp-query-error-hints
Oct 27, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/mcp-query-error-hints

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Problem

These are the most common field and sort errors in sentry/mcp-server telemetry (7 days, extrapolated from 0.3 sampling, so user counts are lower bounds). Each fix was checked against the live API.

  • search_logs with min/max(timestamp): ~2.6K failures from ~470 users. Log timestamps are strings, so the fix is min/max(timestamp_precise) (nanoseconds). Metrics behaves the same way (43 failures).
  • search_errors with first_seen(): ~2.3K failures from ~590 users. That function doesn't exist; use min(timestamp), plus max(timestamp) or last_seen(). About 700 of these came from fields the embedded agent picked.
  • search_errors sorted by issue: ~1K failures from ~270 users. Sentry rejects this sort even when issue is selected; use -count() or issue.id.

Changes

  • New tools/support/search-events/field-hints.ts. It adds a hint only when the request actually sent the rejected expression and Sentry's error message matches it.
    • Hints are fixed text and never include caller input, and Sentry's own message is kept.
    • Anything that doesn't match is re-thrown unchanged as ApiValidationError.
  • Hints are added in two places: the validation failure, and the final Events API 400. The second is needed because the validate endpoint accepts the first_seen() and issue-sort cases.
  • min(timestamp) is added to the embedded agent's errors field list.

Not covered

  • timestamp.to_day / to_hour on spans and logs (~600 failures): there's no clear one-line replacement.
  • Metrics count() arity (~350), p10/p25 (~150), and count(span) (0).

Checks

  • tsc, lint (oxfmt) and all mcp-core tests pass (1837 passed, 6 skipped).
  • Tool definitions are unchanged (10,066 tokens).

Relation to #1669

Task 7.3 moves the explore, traces and logs endpoints onto @sentry/api. These hints only depend on the error being an ApiValidationError and on its message, so they should carry over as long as 400s still map to that class.

via BYK.

--

View Junior Session [Sentry]

The search tools pass Sentry's diagnostic through when it rejects a
field or sort, but the diagnostic does not say what to use instead.
These are the top dataset-specific field failures in `sentry/mcp-server`
over the 7 days to 2026-10-26:

- `search_logs` with `min(timestamp)` or `max(timestamp)`: about 2.6K
  failures from ~470 users. Log timestamps are strings.
- `search_errors` with `first_seen()`: about 2.3K failures from ~590
  users. The errors dataset has `last_seen()` but no `first_seen()`.
- `search_errors` sorted by `issue`: about 1K failures from ~270 users.
  Sentry rejects that sort even when `issue` is selected.

Add a fixed hint when the request sent the rejected expression and
Sentry's diagnostic matches it, as the CLI's Explore field hints do.
Read-only checks confirmed each replacement: `min(timestamp)` and
`last_seen()` on errors, `min/max(timestamp_precise)` on logs and
metrics, and sorting by `issue.id`. The backend diagnostic stays in the
message, and other failures are unchanged. The validate endpoint accepts
`first_seen()` and the `issue` sort, so the final Events API error is
checked too. The hints never include caller input.

The embedded agent's errors field list now includes `min(timestamp)`,
because about 700 of the `first_seen()` failures came from
agent-generated fields.

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

vercel Bot commented Oct 27, 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 Oct 27, 2026 3:01pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 27, 2026
@BYK
BYK enabled auto-merge (squash) October 27, 2026 15:16
@BYK
BYK merged commit b01924c into main Oct 27, 2026
47 of 49 checks passed
@BYK
BYK deleted the fix/mcp-query-error-hints branch October 27, 2026 15:17

This branch was successfully deployed

1 active and 1 inactive deployments
Actions — ef2c9ed3 Deployed Oct 27, 2026 by sentry-junior[bot] via eval #1378
Preview — ef2c9ed3 Deployed Oct 26, 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