Repository navigation
ref(mcp): Use @sentry/api pagination helpers in mcp-core - #2290
Merged
Merged
Conversation
Replace mcp-core's hand-written Link-header parsing and page walks with the SDK's pagination helpers, matching the CLI. - find_dashboards uses paginate() for both org-wide and project-scoped searches. Project-scoped results are filtered per page, and a walk that stops inside a page returns the SDK's resumable cursor instead of the custom mcp-dashboard-project: cursor. - Full-list walks (issue links and integrations, dashboard title resolution, Alert source detector lookup) go through a new fetchEveryPage() wrapper over fetchAllPages(). It throws on a repeated cursor or past MAX_LIST_PAGES instead of looping without a bound or returning a partial list. - getNextCursor() is replaced by the SDK's nextPageCursor(). - Enable sentry-cli/no-manual-pagination for packages/mcp-core/src. Fixes #2287 Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 16, 2026
7 tasks done
This branch was successfully 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.
mcp-core parsed
Linkheaders and walked pages by hand in several places. This PR moves it to the@sentry/api/clientpagination helpers that the CLI already uses, deletes the hand-written walks, and turns on the CLI's lint rule so new ones don't slip back in.find_dashboards now uses
paginate()for both org-wide and project-scoped searches. In a project-constrained session each API page is filtered to the project before it counts towardlimit. A walk that stops partway through a page returns the SDK's resumable cursor (the samelimit:page:is_prevcursor Sentry'sChainPaginatoruses, with the skip count encoded in it). That cursor replaces the custom base64mcp-dashboard-project:cursor, and the per-page size is kept so resuming doesn't shift the page window. The output shape, thelimitbounds and the "fill the page from later pages" behavior stay the same.Full-list walks now go through a small
fetchEveryPage()wrapper overfetchAllPages()inapi-client/pagination.ts. That covers issue external links, issue integrations, Sentry App installations and components, dashboard title resolution, and the Alert sourceissue_streammonitor lookup. These walks used to loop without a bound, or quietly stop when a cursor repeated. They now throw when a cursor repeats or the walk passesMAX_LIST_PAGES, because a partial list could hide the record a lookup depends on.Link parsing:
getNextCursor()is deleted in favor of the SDK'snextPageCursor(response).Lint: the CLI oxlint plugin's
no-manual-paginationrule can now run outsidepackages/cli(therule()helper takes the package dirs it applies to), and it's enabled forpackages/mcp-core/src. Its message now names the helpers to use in each package.Notes for review:
getAIConversationkeeps its bounded loop and only switches tonextPageCursor(). It asks for 1000 spans per page across at most 10 pages and returns whatever it has at the cap. Neither SDK helper does that:paginate()would capper_pageat 100, andfetchAllPages()treats hitting the cap as a failure. The lint rule doesn't flag the loop because it isn't counting toward alimit.mcp-dashboard-project:…) won't resume after it ships. They're opaque, short-lived values that clients get back from the previous call, so I didn't add a compatibility path. The org-wide guard that rejected project cursors is gone too: with plain SDK cursors, reusing one across scopes repeats rows instead of skipping them.docs/contributing/api-patterns.mdnow points to these helpers instead ofparseSentryLinkHeader.Fixes #2287
via @BYK.
--
View Session [Sentry]