Repository navigation
ref(mcp): Call shared organization endpoints from SentryApiService - #1741
Merged
Merged
Conversation
createApiClientCore sends a request through the host's transport with the host's headers, turns network failures into readable errors (ConfigurationError for an unreachable host), maps error responses to the status's ApiError through readErrorResponse, and parses JSON bodies. The transport, headers, and logger are injected, so it stays browser-portable. It is the MCP's request path, moved as is; the next commit switches SentryApiService onto it.
request and requestJSON keep their signatures and delegate to createApiClientCore, so no endpoint method changes. SentryApiService supplies its headers (User-Agent, Authorization, MCP attribution), the shared transport, and logWarn under the api.client scope. Its copies of the network error messages and the error-response mapping are deleted. The one difference: the error-response warnings now log the host the request went to, rather than the service's default host, when a call overrides the host.
…oducts use The shared client builds on @sentry/api operations next. toolkit-core pinned TypeScript through the ^5.8.3 catalog (5.8.3) while mcp-core and the CLI resolve 5.9.3, so adding @sentry/api resolved a second copy with other peers. Using ^5.9.3, as the CLI does, keeps one copy. TypeScript 5.9's DOM BodyInit takes only ArrayBuffer-backed views, so the cache policy now says so when it builds a Response from a decoded body. No runtime change.
sdkClient gives a @sentry/api operation a client that sends one GET to an expected path through the core's request, and rejects any other target or method. listPage walks a list endpoint up to a limit, asking for exactly the rows still missing, and validates each page with the host's Standard Schema. Both are the MCP's sdkClient and sdkListPage, moved as is apart from validation.
endpoints/organizations in toolkit-core has getAuthenticatedUser, listOrganizations, and getOrganization. Each takes an ApiTarget (the request core and an origin) and the host's Standard Schema, and returns that schema's output. SentryApiService calls them with its Zod schemas and keeps choosing the host: the control host for the current user and the organization list on public SaaS. Its sdkClient and the teams and projects lists now use the core's sdkClient and listPage; its own copies are deleted, and so is getAuthenticatedUser's unused options argument. A response that fails its schema in these calls now throws the shared ApiResponseValidationError instead of a ZodError. Both reach the tool error handler as unexpected errors.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
requested changes
Oct 29, 2026
Instead of pinning ^5.9.3 in toolkit-core alone, the pnpm catalog moves from ^5.8.3 to ^5.9.3, and toolkit-core and the CLI go back to `catalog:`. Every workspace package now resolves the same TypeScript 5.9.3, and 5.8.3 drops out of the lockfile.
BYK
approved these changes
Oct 29, 2026
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.
Task 8.4, part 2 of the shared API client stack (#1669). It used to be stacked on #1737, which has merged, so it now targets
main.This adds the first shared endpoint wrappers to
toolkit-core'sapi-client/, and the MCP'sSentryApiServicenow calls them. The code moves as is, so it can go to@sentry/apilater without changes.Changes
endpoints/organizationsaddsgetAuthenticatedUser,listOrganizationsandgetOrganization. Each one takes anApiTarget(the request core plus an origin) and a Standard Schema from the host, and returns that schema's output.toolkit-coredoesn't depend on Zod or valibot when the code runs.sdkClient, which sends one GET to an expected path and rejects any other path or method, andlistPage, which walks a list endpoint up to a limit and validates each page. These are the MCP'ssdkClientandsdkListPage, moved as is. The only change is that validation now uses Standard Schema.SentryApiServicestill decides which host to call: the control host for the current user and for the organization list on public SaaS. Its ownsdkClientandsdkListPagecopies are deleted, and the teams and projects lists use the shared ones.toolkit-corenow depends on@sentry/api. To keep a single TypeScript copy, the pnpm catalog's TypeScript moves from^5.8.3to^5.9.3, andtoolkit-coreand the CLI usecatalog:instead of pinning their own version. Every workspace package now resolves TypeScript 5.9.3, and 5.8.3 drops out of the lockfile. The cache policy changes one type to match TypeScript 5.9's DOMBodyInit. Nothing changes at runtime.One change in behaviour: if a response fails its schema in these calls, the error is now the shared
ApiResponseValidationErrorinstead of aZodError. Both still reach the tool error handler as unexpected errors.--
View Junior Session in Sentry