Skip to content

fix(mcp): Allow empty or scheme-less organizationUrl for self-hosted Sentry - #2361

Open
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix-mcp-self-hosted-organization-url
Open

sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix-mcp-self-hosted-organization-url

Conversation

@sentry

@sentry sentry Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When listing organizations on a self-hosted Sentry instance, listOrganizations fails with an ApiResponseValidationError: Unexpected API response: 0.links.organizationUrl: Invalid URL.

Self-hosted Sentry instances construct links.organizationUrl from their system.url-prefix setting when no organization URL template is configured. On instances where system.url-prefix is unset, empty, or configured without a scheme, Sentry sends back an invalid URL string or an empty string, causing OrganizationSchema to reject the response.

Changes

  • Revert the strict z.string().url() constraint on links.organizationUrl in packages/mcp-core/src/api-client/schema.ts to keep strict schema validation per reviewer guidance, or document why misconfigured self-hosted installations are expected to configure system.url-prefix as a valid absolute URL.

Fixes CLI-49Q

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@sentry
sentry Bot requested a review from a team as a code owner November 18, 2026 10:47
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 18, 2026 5:25pm UTC

Request Review

@sentry
sentry Bot deployed to Actions November 18, 2026 10:47 Active
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 18, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I checked the premise against the producer in getsentry/sentry. The organization serializer sets links.organizationUrl from generate_organization_url(), and with no SENTRY_ORGANIZATION_URL_TEMPLATE (the self-hosted default) that returns the system.url-prefix option as-is. Nothing normalizes it, so whatever an admin typed, such as a host with no scheme, comes back. The linked issue matches: a stdio @sentry/mcp-server 0.49.0 user on a self-hosted host gets a 200 from GET /api/0/organizations/, and then 0.links.organizationUrl: Invalid URL. That means the value is a string but not a URL, so every org-scoped tool that lists orgs breaks for that install.

The fix is at the right boundary. The schema now accepts any string, and find_organizations maps anything that isn't an absolute URL to webUrl: null. That keeps its output schema (z.string().url().nullable()) honest, and we don't guess a scheme. regionUrl handling is unchanged apart from trimming, and find_organizations is the only consumer of organizationUrl in the repo. I merged the branch with current main and ran the checks there: mcp-core tsc and oxlint on the changed files are clean, and schema.test.ts and find-organizations.test.ts pass. The new schema cases fail against main's schema, so they really cover the bug.

)
.optional(),
organizationUrl: z.string().url(),
// Self-hosted Sentry returns `system.url-prefix` here, which may be

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure that is just a misconfigured Sentry installation, right? If that's so, we don't need to handle it here and attempt to solve a bunch of other edge cases.

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 18, 2026

This branch was successfully deployed

1 active (outdated) and 1 inactive deployments
Preview — 82a593b0 Deployed Nov 18, 2026 by vercel[bot]
Actions — 1e14731b Deployed Nov 18, 2026 by sentry[bot] via eval #1956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant