Repository navigation
feat(mcp): Default organizationSlug to the user's only organization - #1836
Merged
Merged
Conversation
A tool call that omits organizationSlug now uses the organization when the login can access exactly one. With several, a tool that requires it fails with a ready-to-run retry and the list of organizations, the same recovery the CLI added in #1634. The server never picks between organizations. Tool registration makes a required organizationSlug optional, and the shared param-prep step fills it before credential routing, so no tool schema or handler changes. The organization list is fetched through the shared client and memoized per context for five minutes. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c2b69b. Configure here.
With several logins, a login whose organization listing fails is skipped, so one remaining organization could be defaulted while the failed login hid another. Default only when every login answered; otherwise the required-slug error says some logins could not list their organizations. A partial list is not memoized.
…l URL The URL check that lets a Sentry URL stand in for organizationSlug also ran for tools that require the slug. Uptime monitor tools take their target as `url`, so https://example.com/health was read as organization "example" and the default was skipped. Only optional slugs check URLs now; a tool that requires the slug never reads it from a URL.
BYK
approved these changes
Nov 3, 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.

When a tool call leaves out
organizationSlugand the login can reach exactly one organization, the call now uses that organization. When the login can reach several, a tool that requires the slug fails with a retry the model can run as is, plus the other organizations. This is the MCP version of the CLI recovery in #1634, and it finishes the part #1678 held back. The server never chooses between organizations.Why now
Over the last 7 days (
sentry/mcp-serverspans, extrapolated counts):organizationSlug: Requiredfailures: about 4.3K, from search_issues, find_projects, search_errors, search_logs, and calls through execute_sentry_tool.get_sentry_resourceadds about 1.9K more with "organizationSlugis required when not using a URL".How it works
getFilteredInputSchemamakes a requiredorganizationSlugoptional at registration time, so the MCP SDK no longer rejects the call before our code runs. ThenprepareToolCallParamsrunsapplyDefaultOrganization. Both top-level calls andexecute_sentry_toolgo through it, beforewithRoutedCredential, so stdio account routing (feat(mcp-server): Route stdio tool calls to the stored account that knows the org #1802) gets the defaulted slug.getTargetOrganizationSlug). Org-scoped sessions never reach it.regionUrland the caller didn't set one, the call also gets the organization'sregionUrl. On self-hosted that value is empty, soregionUrlstays unset.Retry example: `search_issues(organizationSlug='org-a', period='1h')`and lists the other organizations. Catalog tools get theexecute_sentry_tool(name=…, arguments=…)form, and values equal to a schema default are left out. For an optional slug (URL-or-ID tools such asget_sentry_resource), the call runs as before.org:read): the error falls back to the find_organizations hint from fix(mcp): Accept 1h and minute periods; guide models to find_organizations on missing org #1678.Fit with #1669
SentryApiService.listOrganizations, which already uses the sharedendpoints/organizationswrapper and transport (ref(mcp): Send Sentry API requests through the shared transport #1722, ref(mcp): Send SentryApiService requests through a shared request core #1737). No new endpoint code.CacheStoreyet (7.1 is still open). Instead, the list is memoized per context and credential for 5 minutes, which matches thestabletier. When 7.1 lands, the/organizations/request gets cached per identity on its own, and this memo can be dropped. It doesn't conflict with 8.4–8.7 or 11.x.Token cost
measure-tokensis unchanged at 9,014. That script reads the raw tool schemas, and those didn't change. In the registered schemas,organizationSlugis no longer in therequiredlist on 8 direct tools, which comes to 5,014 → 4,990 input-schema tokens.Open questions
nullslug still gets the find_organizations hint. Acceptingnullwould addanyOfto every schema.get_sentry_resourceis called by a user with several organizations, it keeps its own error. It doesn't list the organizations yet.via @BYK.
--
View Session [Sentry]