Skip to content

ref(mcp): Call shared trace, profiling, and snapshot endpoints - #1841

Merged
BYK merged 1 commit into
ref/shared-uptime-monitor-endpointsfrom
ref/shared-trace-profile-snapshot-endpoints
Nov 3, 2026
Merged

BYK merged 1 commit into
ref/shared-uptime-monitor-endpointsfrom
ref/shared-trace-profile-snapshot-endpoints

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Task 8.4 of the shared API client plan (#1669). This is stacked on #1840.

This moves the trace, profiling, and preprod snapshot endpoints from SentryApiService into toolkit-core's api-client/endpoints/. SentryApiService calls them with its Zod schemas. The code moves as is.

  • endpoints/traces: getTraceMeta and getTrace, with the same defaults (14d, limit=1000, project=-1).
  • endpoints/profiling: getFlamegraph (still escapes the transaction name), getTransactionProfile, and getProfileChunks. SentryApiService.getProfileChunk keeps the MCP-only shaping: it throws ApiNotFoundError when there are no chunks and backfills profiler_id.
  • endpoints/snapshots: getSnapshot, getSnapshotImage, and getLatestBaseSnapshot. They return the body unvalidated, as before. fetchImageByUrl stays in SentryApiService, since it isn't an endpoint.

@sentry/api has operations for all of these routes. The wrappers still build their requests by hand so the change stays a move. Switching them to the operations can follow.

Intentional changes:

  • As with ref(mcp): Call shared organization endpoints from SentryApiService #1741, a response that fails its schema now throws the shared ApiResponseValidationError instead of a ZodError.
  • getSnapshot with compactMetadata: false no longer sends a trailing ? with an empty query.
  • The ApiNotFoundError for an empty chunk list carries the validated body as responseBody, not the raw one.

Checked with pnpm run tsc, pnpm run lint, pnpm run docs:check, and the toolkit-core, mcp-core, mcp-server bundle, and mcp-cloudflare tests on the top of the stack, plus the trace, profile, and snapshot tool tests on this commit.

via @BYK.

--

View Session [Sentry]

@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 11:16am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
@sentry-junior
sentry-junior Bot force-pushed the ref/shared-trace-profile-snapshot-endpoints branch from 8c0252f to 8593c2e Compare November 3, 2026 10:34
@sentry-junior
sentry-junior Bot force-pushed the ref/shared-trace-profile-snapshot-endpoints branch from 8593c2e to 31c0c0e Compare November 3, 2026 10:48
Moves the trace, trace meta, flamegraph, transaction profile, profile
chunk, and preprod snapshot endpoints from SentryApiService into
toolkit-core's shared API client, as is. SentryApiService keeps the
profile chunk unwrapping and profiler_id backfill.

Co-Authored-By: Burak Yigit Kaya <126780+BYK@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the ref/shared-trace-profile-snapshot-endpoints branch from 31c0c0e to c996486 Compare November 3, 2026 11:14
@BYK
BYK added this pull request to stack #1851 November 3, 2026 12:12
@BYK
BYK merged commit 93696f1 into main Nov 3, 2026
52 of 53 checks passed
@BYK
BYK deleted the ref/shared-trace-profile-snapshot-endpoints branch November 3, 2026 12:13
BYK added a commit that referenced this pull request Nov 3, 2026
Task 8.4 of the shared API client plan
([#1669](#1669)). This is
stacked on #1841 and is the last PR in the stack.

This moves the replay endpoints from `SentryApiService` into
`toolkit-core`'s `api-client/endpoints/replays`. `SentryApiService`
calls them with its Zod schemas. The code moves as is.

- `searchReplays` keeps the same query: `query`, `per_page`, `project`,
`sort`, repeated `environment` and `field`, and the time range.
- `getReplay` and `listIssueReplayIds`. `SentryApiService` still unwraps
the `{ data }` envelope and picks the issue's entry from the keyed
replay-count result.
- `visitReplayRecordingSegments` still pages 100 segments at a time,
follows the `Link` cursor, and stops at `maxSegments`, with `truncated`
set the same way as before. It reads the cursor with the shared
`nextPageCursor`, which parses the header the same way the old
`getNextCursor` did.
- `docs/contributing/api-patterns.md` gets a short "Where Endpoint Code
Lives" section that describes the pattern this stack follows.

**One change in behaviour:** as with #1741, a response that fails its
schema now throws the shared `ApiResponseValidationError` instead of a
`ZodError`.

Checked with `pnpm run tsc`, `pnpm run lint`, `pnpm run docs:check`, and
the toolkit-core, mcp-core, mcp-server bundle, and mcp-cloudflare tests
on this branch before the last rebase. `pnpm run tsc` passes again after
rebasing onto the current main.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ab061171f2ec2e6cf6f09a6828cadc9fa -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ab061171f2ec2e6cf6f09a6828cadc9fa)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab061171f2ec2e6cf6f09a6828cadc9fa/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Burak Yigit Kaya <126780+BYK@users.noreply.github.com>
sentry-junior Bot added a commit that referenced this pull request Nov 3, 2026
Resolve the client.ts conflict with #1841, which moved
getTransactionProfile to the shared toolkit-core endpoint. Pass a
TransactionProfileResponseSchema that validates speedscope bodies with
LegacySpeedscopeProfileSchema and every other body with the strict
TransactionProfileSchema. Add a test that a sample-format body without
profile data is still rejected.

This branch was successfully deployed

1 active deployment
Preview — c9964864 Deployed Nov 3, 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