Skip to content

Self-hosted Sentry with mixed-case org slug returns 404 — slug params force .toLowerCase() #1138

Closed

Description

@RavenLiao

Summary

@sentry/mcp-server forces all organization / project / team slug parameters through .toLowerCase() in their Zod schemas. On self-hosted Sentry instances — where slugs are case-sensitive — this makes every tool call against an org whose slug contains uppercase letters fail with HTTP 404, even though the token and host are correct.

Sentry SaaS slugs are always lowercase, so the lowercasing is invisible there. Self-hosted instances can have mixed-case slugs (e.g. MyOrg), and the API treats MyOrg ≠ myorg.

Environment

  • @sentry/mcp-server: 0.36.0
  • Deployment: self-hosted Sentry
  • Org slug on instance: mixed-case (contains uppercase letters)

Reproduction

Token is valid; whoami works; the org is listed by find_organizations.

Call Result
find_projects(organizationSlug="MyOrg") (actual slug) 404
find_projects(organizationSlug="myorg") (lowercased) 404
search_issues(organizationSlug="MyOrg", projectSlugOrId=<id>) 404
Direct REST GET /api/0/organizations/MyOrg/ (Bearer token) 200 ✅
Direct REST GET /api/0/organizations/MyOrg/projects/ 200 ✅
Direct REST GET /api/0/organizations/myorg/projects/ (lowercase) 404

So the token, host, org and project all exist and are accessible via the REST API. The 404 is caused purely by the MCP server lowercasing the slug before sending it.

Root cause

In dist/index.js (v0.36.0), the slug parameters are defined with a hardcoded .toLowerCase():

// dist/index.js:328-331
const ParamOrganizationSlug  = z.string().toLowerCase().trim().superRefine(validateSlug)...
const ParamTeamSlug          = z.string().toLowerCase().trim().superRefine(validateSlug)...
const ParamProjectSlug       = z.string().toLowerCase().trim().superRefine(validateSlug)...
const ParamProjectSlugOrAll  = z.string().toLowerCase().trim().superRefine(validateSlug)...

The same pattern repeats for projectSlugOrId params:

// dist/index.js:12989  (find_releases)
projectSlugOrId: z.string().toLowerCase().trim().superRefine(validateSlugOrId)...

// dist/index.js:34094  (search_issues)
projectSlugOrId: z.string().toLowerCase().trim().superRefine(validateSlugOrId)...

… and the create_project slug field (dist/index.js:33202).

Note: validateSlug itself is not the problem — its regex /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/ already allows uppercase. The .toLowerCase() in the schema chain is the sole cause.

Expected behaviour

Slug case is preserved as provided by the caller. On self-hosted instances with case-sensitive slugs, find_projects(organizationSlug="MyOrg") should hit /api/0/organizations/MyOrg/projects/ and succeed.

Suggested fix

Options (any one resolves it):

  1. Add a --preserve-slug-case flag (or auto-detect self-hosted mode) that skips .toLowerCase() on slug params. Default behavior unchanged for SaaS.
  2. Drop .toLowerCase() entirely from ParamOrganizationSlug / ParamTeamSlug / ParamProjectSlug / ParamProjectSlugOrAll / projectSlugOrId params. validateSlug already enforces a safe charset, so removing the lowercasing does not weaken injection protection. (Platform param can stay lowercased — platform names are conventionally lowercase.)
  3. At minimum, document that org/project slugs are coerced to lowercase and therefore self-hosted instances must use all-lowercase slugs.

Workaround

Patch the installed package locally: remove the .toLowerCase() calls on slug params in dist/index.js, pin the version, and point the MCP config at the patched binary. Works but breaks on upgrade.

Activity

  1. linear-code commented on Jun 30, 2026

    @linear-code
  2. added
    bug
    on Jun 30, 2026
  3. sentry-pierre commented on Jun 30, 2026

    @sentry-pierre

    Hi, I'm Pierre!

    This checks out. I confirmed the .toLowerCase() chain is hardcoded in the source:

    • packages/mcp-core/src/schema.ts — ParamOrganizationSlug, ParamTeamSlug, ParamProjectSlug, and ParamProjectSlugOrAll all call .toLowerCase().
    • packages/mcp-core/src/tools/catalog/search-issues.ts — ProjectSlugOrIdSchema does the same.
    • packages/mcp-core/src/utils/slug-validation.ts — validateSlug already allows uppercase characters (/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/), so the lowercasing isn't needed for security.

    The find_projects tool feeds the lowercased slug straight into apiService.listProjects(), which hits /organizations/${organizationSlug}/projects/. On a self-hosted instance where MyOrg ≠ myorg, that's a guaranteed 404.

    You're right — removing .toLowerCase() from the slug param schemas should fix it without weakening injection protection.

    Merci for the detailed report.

  4. dcramer commented on Jun 30, 2026

    @dcramer
    Member

    it looks like this was fixed in 23.2.0 and then fully fixed in 25.5.0. There are many things that will break in this MCP server with old versions of Sentry

    • Short version: Sentry self-hosted before 23.2.0 could create mixed-case organization slugs. Starting in 23.2.0, new org slugs are lowercased on save. Starting in 25.5.0, uppercase org
      slugs are rejected by the API serializer.
    
      Evidence from ~/src/sentry:
    
      - 23.1.1 tests accepted uppercase org slugs: valid_slugs = ["santry", ..., "SaNtRy"].
      - Commit 244082c88aa on 2023-01-31, included in 23.2.0, changed org save from:
        slugify_target.replace("_", "-")
        to:
        slugify_target.lower().replace("_", "-")
    
      - Commit 8a80bce28bf on 2025-05-12, included in 25.5.0, added serializer validation rejecting uppercase org slugs.
      - Current lookup code still compares slugs exactly through slug__id_or_slug, whose SQL path does slug = rhs, not iexact.
    

    If you have more concerns please re-open but I'm going to clsoe as wontfix because of that.

  5. RavenLiao commented on Jul 2, 2026

    @RavenLiao
    Author

    Thanks for the detailed investigation. But your own evidence actually shows the problem is the MCP's .toLowerCase(), not "old versions being broadly unusable":

    1. Your evidence supports pass-through, not lowerca

    You note that Sentry's lookup goes through slug = rhs (exact, case-sensitive), not iexact. Our org slug is a legacy mixed-case one (call it MyOrg), and that's exactly how it's stored. So:

    • Pass MyOrg through unchanged → slug = 'MyOrg' → exact match ✓
    • MCP lowercases to myorg → slug = 'myorg' → no match → 404 ✗

    Precisely because Sentry matches exactly, the MCP's forced .toLowerCase() is the sole cause of the 404. Pass the slug through unchanged and Sentry's own API resolves it fine.

    1. 23.2.0 / 25.5.0 do not migrate existing slugs.

    23.2.0 only lowercases on save; 25.5.0 only rejects uppercase on save. Neither migrates slugs that already exist. So a legacy mixed-case slug stays mixed-case after upgrade, and the only remediation is a risky manual rename — but the org slug is baked into our app build/runtime config (SENTRY_ORG for symbol/source-map upload), CI, and dashboards, so renaming is a costly, coordinated change. Upgrading alone does not fix this.

    1. "Many things break on old Sentry" doesn't hold for this feature.
      We have direct evidence: with the .toLowerCase() removed (pass-through patch), this MCP fully works on our self-hosted instance — issue, event, and release queries all return data. n was that one line. So this isn't "old versions are unusable and not worth supporting"; it's a one-line defensive fix with zero impact on new versions.

    Ask: please reconsider — either (a) pass the slug through unchanged, or (b) add a config flag to disable lowercasing. New installs already have lowercase slugs post-23.2.0, so pass-td only helps legacy ones.

    Also: I don't have write access to the repo, so I can't re-open this myself — could you re-open it based on the above?

  6. reopened this on Jul 2, 2026
  7. dcramer commented on Jul 2, 2026

    @dcramer
    Member

    @RavenLiao ah i must not have read close enough. Will try to dig more today, ty

  8. added a commit that references this issue on Jul 2, 2026
    ed572b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    State: Unreproduciblebug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions