Repository navigation
feat(mcp): Return structured output from search_errors - #1987
Merged
Merged
Conversation
search_errors now declares an outputSchema and returns structuredContent on every success path: sample rows, aggregate rows, and time series. Rows carry only the requested fields plus derived issue links, so upstream keys the search did not ask for never reach the model. The presentation hint, dashboard link, empty-result guidance, Seer and environment notes, and dropped-event notes move into named fields. The first matching issue becomes a get_issue_details suggested action. The shared pieces live in search-events/structured.ts so the other dataset tools can opt in one at a time. The legacy search_events tool keeps its markdown output. Co-Authored-By: David Cramer <[email protected]>
- Declare each dataset's row-link Zod shape in its structured config and derive the output schema from it, so rowLinks and the schema cannot drift apart. - Require lockDataset when runSearchEvents returns structured output. - Point the issue follow-up at get_sentry_resource. - Snapshot the full time-series payload and assert passthrough keys from the series, bucket, and ingestion metadata never reach the result. - Describe the structured payload in the search-events spec. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Copy suggested-actions.ts and ai-conversation-actions.ts byte-for-byte from the get_replay_details change, which exports MAX_SUGGESTED_ACTIONS and SuggestedActionValue, so every structured-output branch adds the same bytes and they merge cleanly in any order. Co-Authored-By: David Cramer <[email protected]>
This was referenced Nov 5, 2026
dcramer
added a commit
that referenced
this pull request
Nov 5, 2026
`search_logs` now declares an `outputSchema` and returns `structuredContent` on every success path. It uses the shared dataset search payload from #1987 and follows the Structured Content policy in `docs/contributing/tool-responses.md`. The model now sees pretty JSON instead of markdown. - Rows carry only the requested fields in `values`, plus derived `logUrl` and `traceUrl` links in `links`, mapped explicitly. - The console-style presentation hint and empty-result guidance move into named fields. - The first row with a trace becomes a `get_sentry_resource` suggested action. - Tests snapshot `structuredContent` and assert that passthrough API fields don't leak. **Stack and merge order:** #1987 (search_errors) → logs → traces → metrics → profiles → replays (the replays PR isn't open yet). This PR targets `feat/search-errors-structured-output` and is 1st after #1987 in the stack. Merge in that order; GitHub retargets each PR as its base merges. - If #1987 or a parent PR is squash-merged, rebase this branch with `git rebase --onto <new base> <old parent head> <this branch>` so the parent's commits don't replay. - `toolDefinitions.json` will conflict along the stack and with the sibling structured-output PRs. Regenerate it on rebase with `pnpm run --filter @sentry/mcp-core generate-definitions`. - The shared `suggested-actions.ts` / `ai-conversation-actions.ts` come from #1987 and are byte-identical to the canonical copies (blobs `ee84917` / `63ff7bd`). **Tokens** - `measure-tokens` total is unchanged at 47,079: the description and input schema are unchanged, and the script doesn't count `outputSchema`. - `outputSchema` adds ~745 tokens to `tools/list`. - Per call on a realistic fixture: markdown 2478 → JSON 2679 tokens (1.08x). **Checks:** package-scoped only, run with `SENTRY_AUTH_TOKEN` unset. - `pnpm run --filter @sentry/mcp-core generate-definitions`, `pnpm --filter @sentry/mcp-core run tsc`, `pnpm run lint` - full mcp-core vitest on the top stacked branch (profiles): 146 files, 2096 passed, 6 skipped; on this branch, tool-helpers + search-events + search tool tests: 337 passed - Root `pnpm run tsc` was not run because its cloudflare build uploads source maps. Evals were skipped because they need API keys. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A018aa877508ecba7895b5d9d7ca8674a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 5, 2026
`search_traces` now declares an `outputSchema` and returns `structuredContent` on every success path, using the shared dataset search payload from #1987. The model now sees pretty JSON instead of markdown. - Rows carry only the requested fields, plus a derived `traceUrl` link. - The timeline presentation hint and empty-result guidance move into named fields. - A note says `span.duration` values are in milliseconds; the markdown appended "ms". - The first row with a trace becomes a `get_sentry_resource` suggested action. - Tests snapshot `structuredContent` and assert that passthrough fields don't leak. **Stack and merge order:** #1987 (search_errors) → logs → traces → metrics → profiles → replays (the replays PR isn't open yet). This PR targets `feat/search-logs-structured-output` and is 2nd after #1987 in the stack. Merge in that order; GitHub retargets each PR as its base merges. - If #1987 or a parent PR is squash-merged, rebase this branch with `git rebase --onto <new base> <old parent head> <this branch>` so the parent's commits don't replay. - `toolDefinitions.json` will conflict along the stack and with the sibling structured-output PRs. Regenerate it on rebase with `pnpm run --filter @sentry/mcp-core generate-definitions`. - The shared `suggested-actions.ts` / `ai-conversation-actions.ts` come from #1987 and are byte-identical to the canonical copies (blobs `ee84917` / `63ff7bd`). **Tokens** - `measure-tokens` total is unchanged at 47,079: the description and input schema are unchanged, and the script doesn't count `outputSchema`. - `outputSchema` adds ~732 tokens to `tools/list`. - Per call on a realistic fixture: markdown 1876 → JSON 2199 tokens (1.17x). **Checks:** package-scoped only, run with `SENTRY_AUTH_TOKEN` unset. - `pnpm run --filter @sentry/mcp-core generate-definitions`, `pnpm --filter @sentry/mcp-core run tsc`, `pnpm run lint` - full mcp-core vitest on the top stacked branch (profiles): 146 files, 2096 passed; on this branch, tool-helpers + search-events + search tool tests: 340 passed - Root `pnpm run tsc` was not run because its cloudflare build uploads source maps. Evals were skipped because they need API keys. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A018aa877508ecba7895b5d9d7ca8674a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 5, 2026
`search_metrics` now declares an `outputSchema` and returns `structuredContent` on every success path, using the shared dataset search payload from #1987. The model now sees pretty JSON instead of markdown. - Rows carry only the requested fields, plus a derived `traceUrl` link. - The follow-up action opens the first sample's trace with `get_sentry_resource`. - Metric presentation hints move into `METRIC_RESULT_HINTS`, so markdown and structured output share them. - Tests snapshot `structuredContent` and assert that passthrough fields don't leak. **Stack and merge order:** #1987 (search_errors) → logs → traces → metrics → profiles → replays (the replays PR isn't open yet). This PR targets `feat/search-traces-structured-output` and is 3rd after #1987 in the stack. Merge in that order; GitHub retargets each PR as its base merges. - If #1987 or a parent PR is squash-merged, rebase this branch with `git rebase --onto <new base> <old parent head> <this branch>` so the parent's commits don't replay. - `toolDefinitions.json` will conflict along the stack and with the sibling structured-output PRs. Regenerate it on rebase with `pnpm run --filter @sentry/mcp-core generate-definitions`. - The shared `suggested-actions.ts` / `ai-conversation-actions.ts` come from #1987 and are byte-identical to the canonical copies (blobs `ee84917` / `63ff7bd`). **Tokens** - `measure-tokens` total is unchanged at 47,079: the description and input schema are unchanged, and the script doesn't count `outputSchema`. - `outputSchema` adds ~732 tokens to `tools/list`. - Per call on a realistic fixture: markdown 1937 → JSON 2262 tokens (1.17x). **Checks:** package-scoped only, run with `SENTRY_AUTH_TOKEN` unset. - `pnpm run --filter @sentry/mcp-core generate-definitions`, `pnpm --filter @sentry/mcp-core run tsc`, `pnpm run lint` - full mcp-core vitest on the top stacked branch (profiles): 146 files, 2096 passed; on this branch, tool-helpers + search-events + search tool tests: 343 passed - Root `pnpm run tsc` was not run because its cloudflare build uploads source maps. Evals were skipped because they need API keys. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A018aa877508ecba7895b5d9d7ca8674a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 5, 2026
`search_profiles` now declares an `outputSchema` and returns `structuredContent` on every success path, using the shared dataset search payload from #1987. The model now sees pretty JSON instead of markdown. - Rows carry only the requested fields, plus derived `profileUrl` (transaction or continuous-profile flamegraph, via the now-exported `getProfileDetailUrl`) and `traceUrl` links. - Notes say `transaction.duration` and `profile.duration` are in nanoseconds; the markdown formatted them. - Suggested actions open the first profile with `get_profile_details` (`get_sentry_resource` in experimental mode, as the markdown advised) and the first trace with `get_sentry_resource`. - Tests snapshot `structuredContent` and assert that passthrough fields don't leak. **Stack and merge order:** #1987 (search_errors) → logs → traces → metrics → profiles → replays (the replays PR isn't open yet). This PR targets `feat/search-metrics-structured-output` and is 4th after #1987 in the stack. Merge in that order; GitHub retargets each PR as its base merges. - If #1987 or a parent PR is squash-merged, rebase this branch with `git rebase --onto <new base> <old parent head> <this branch>` so the parent's commits don't replay. - `toolDefinitions.json` will conflict along the stack and with the sibling structured-output PRs. Regenerate it on rebase with `pnpm run --filter @sentry/mcp-core generate-definitions`. - The shared `suggested-actions.ts` / `ai-conversation-actions.ts` come from #1987 and are byte-identical to the canonical copies (blobs `ee84917` / `63ff7bd`). **Tokens** - `measure-tokens` total is unchanged at 47,079: the description and input schema are unchanged, and the script doesn't count `outputSchema`. - `outputSchema` adds ~745 tokens to `tools/list`. - Per call on a realistic fixture: markdown 2507 → JSON 3039 tokens (1.21x). **Checks:** package-scoped only, run with `SENTRY_AUTH_TOKEN` unset. - `pnpm run --filter @sentry/mcp-core generate-definitions`, `pnpm --filter @sentry/mcp-core run tsc`, `pnpm run lint` - full mcp-core vitest on this branch: 146 files, 2096 passed, 6 skipped - Root `pnpm run tsc` was not run because its cloudflare build uploads source maps. Evals were skipped because they need API keys. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A018aa877508ecba7895b5d9d7ca8674a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 5, 2026
`search_replays` now declares an `outputSchema` and returns
`structuredContent` on every success path, following the Structured
Content policy in `docs/contributing/tool-responses.md`. The model now
sees pretty JSON instead of markdown.
**Payload**
- `searchReplaysOutputSchema` and `buildStructuredReplayResults` in
`replays.ts` map replay fields explicitly:
- id, `replayUrl`, start time, duration
- error/rage/dead click counts
- environment and browser
- `isArchived`
- **User.** Explicit `{id, username, email, ip}`, matching
get_replay_details, instead of the upstream-computed display name. The
tool returns the user data Sentry stored. Tags, SDK and other internal
fields stay out, and a no-leak test checks this. `user` is null for
archived replays, whose rows carry placeholder data ("Archived Replay"
as the id).
- **Lists.** URLs, trace IDs and releases are previewed at 3 each.
`urlCount`, `traceCount` and `releaseCount` give the totals.
- **Suggested actions.** `get_replay_details` for the first replay, plus
`get_sentry_resource` for its first trace.
- Adds a replay overload to `runSearchEvents` and exports
`timeRangeSchema` from `structured.ts`.
**Stack and merge order**
- Order: #1987 (search_errors) → #2006 logs → #2008 traces → #2010
metrics → #2012 profiles → this PR. It targets
`feat/search-profiles-structured-output`. Merge in that order; GitHub
retargets each PR as its base merges.
- **Merge after #2019, or keep the pinned-user test.** The mapping test
pins its own user instead of reading the shared `replay-details.json`
fixture. #2019 adds `username: "taylor"` to that fixture, which would
otherwise break this snapshot.
- If #1987 or a parent PR is squash-merged, rebase with `git rebase
--onto <new base> <old parent head>
feat/search-replays-structured-output`.
- `toolDefinitions.json` will conflict along the stack and with the
sibling structured-output PRs. Regenerate it on rebase with `pnpm run
--filter @sentry/mcp-core generate-definitions`.
**Tokens**
- `measure-tokens` total is unchanged at 47,079. The description and
input schema are unchanged, and the script doesn't count `outputSchema`.
- `outputSchema` adds ~629 tokens to `tools/list`.
- Per call on a realistic fixture: markdown 1930 → JSON 3191 tokens
(1.65x).
**Checks.** All package-scoped, with `SENTRY_AUTH_TOKEN` unset:
- `pnpm --filter @sentry/mcp-server-mocks run build`
- `pnpm run --filter @sentry/mcp-core generate-definitions`, then `git
status`; only the intended files changed
- `pnpm --filter @sentry/mcp-core run tsc`
- full mcp-core vitest: 147 files, 2101 passed, 6 skipped
- `pnpm run lint`
Root `pnpm run tsc` was not run because its cloudflare build uploads
source maps. Evals were skipped because they need API keys.
<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A018aa877508ecba7895b5d9d7ca8674a -->
--
[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A018aa877508ecba7895b5d9d7ca8674a/?project=4510944073809921)
<!-- junior-session-footer:end -->
---------
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
7 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
search_errorsnow declares anoutputSchema. Every success path returnsstructuredContent: sample rows, aggregate rows, and time series. This follows the Structured Content policy indocs/contributing/tool-responses.md.What the model sees: pretty JSON instead of markdown. Everything the markdown showed has a named field:
presentationHint: the presentation hint plus the dashboard-link hint.url: the dashboard link.notes[]: empty-result guidance, plus the Seer, unknown-environment, project-suggestion, and dropped-events notes.resultType:samples,aggregates, ortimeSeries.timeSeries: total, peak, ingestion, and per-bucketincomplete/outsideRetention, capped at 48 buckets with abucketCount.suggestedActions: oneget_sentry_resourceissue action for the first matching issue. It goes throughexecute_sentry_toolwhen that tool is catalog-only, and is omitted when the tool isn't available.The generic "Next Steps" bullets are dropped, per the doc.
No-leak:
valuesholds only the requested fields, andlinksholds the derivedissueUrl.Shared pieces, so other dataset tools can opt in one at a time:
support/search-events/structured.ts: each dataset config declares its row-link Zod shape, andbuildSearchEventsOutputSchema(dataset)derives the schema from it.rowLinksis typed against that shape, so a key mismatch is a compile error.runSearchEventstakesoutput: "structured", which the types only allow together withlockDataset: true.internal/tool-helpers/suggested-actions.tsaddsbuildSuggestedToolAction.ai-conversation-actions.tsnow uses it, with no behavior change.formatters.tsextractssummarizeTimeSeriesand shared hint constants. Markdown output is unchanged.search_eventsstays markdown.docs/specs/search-events.mddocuments the structured payload.Token cost:
measure-tokenstotal is unchanged at 47,079, because the script does not countoutputSchema.tools/listcost for this tool is about 738 tokens of description and input plus about 732 tokens of outputSchema (tiktoken).Stacking and conflicts:
toolDefinitions.jsonwill conflict with the sibling outputSchema PRs. Regenerate it on rebase withpnpm run --filter @sentry/mcp-core generate-definitions.Checks:
pnpm --filter @sentry/mcp-core run tscpassed.pnpm run lintpassed.generate-definitionswas run.pnpm run tscwas not used for the final pass: its mcp-cloudflare build uploads source maps to Sentry.A separate review pass came back ready with no must-fix items. Its follow-ups are in d384421.
via @dcramer.
--
View Session [Sentry]