Skip to content

feat(mcp): Return structured output from search_logs - #2006

Merged
dcramer merged 1 commit into
mainfrom
feat/search-logs-structured-output
Nov 5, 2026
Merged

dcramer merged 1 commit into
mainfrom
feat/search-logs-structured-output

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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 feat(mcp): Return structured output from search_errors #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 feat(mcp): Return structured output from search_errors #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.

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 9:47pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
Base automatically changed from feat/search-errors-structured-output to main November 5, 2026 21:46
search_logs now declares an outputSchema and returns structuredContent
on every success path, using the shared dataset search payload from
search_errors.

Rows carry the requested fields plus derived logUrl and traceUrl links.
The console-style presentation hint and empty-result guidance move into
named fields, and the first row with a trace becomes a
get_sentry_resource suggested action.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer force-pushed the feat/search-logs-structured-output branch from b5ef42f to a56eec6 Compare November 5, 2026 21:46
@dcramer
dcramer merged commit d1df663 into main Nov 5, 2026
34 checks passed
@dcramer
dcramer deleted the feat/search-logs-structured-output branch November 5, 2026 22:20
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]>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — a56eec66 Deployed Nov 5, 2026 by vercel[bot]
Actions — a56eec66 Deployed Nov 5, 2026 by dcramer via eval #1630
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