Skip to content

Add action to link JIRA and GitHub issues #228

Closed

Description

@haggrip

I use the MCP to quickly generate Tickets and GitHub PRs. However, I can not link them through the MCP, and need to navigate to the Sentry issue and manually link them.

Activity

  1. changed the title [-]Add option to link JIRA and GitHub issues[/-] [+]Add action to link JIRA and GitHub issues[/+] on May 28, 2025
  2. oddgames-david commented on Jun 28, 2025

    @oddgames-david

    Linear also please (all integrations)

  3. wookasz commented on Mar 9, 2026

    @wookasz

    This functionality would be fantastic.

  4. SimonMacIntyre commented on Apr 15, 2026

    @SimonMacIntyre

    This is a big point of friction for me, would love to see it implemented!

  5. otemnov commented on May 28, 2026

    @otemnov

    really need this!

  6. sentry-junior commented on May 28, 2026

    @sentry-junior
    Contributor

    Ran into a related pain point: tried to associate user feedback with a Linear issue via MCP, but you can't modify external issues directly — you have to use the integration-platform endpoint (create-or-update-an-external-issue) instead. The current update_issue tool doesn't expose this. Would be great to have this covered as part of the broader linked-issue support.

    Action taken on behalf of Nick Meisenheimer.

  7. sentry-junior commented on May 28, 2026

    @sentry-junior
    Contributor

    Implementation Proposal: External Issue Linking via update_issue

    Background

    The integration platform endpoint for creating/updating external issue links is:

    POST /api/0/sentry-app-installations/{uuid}/external-issues/
    Body: { issueId: integer, webUrl: string, project: string, identifier: string }
    Scope: event:write  ← already required by update_issue
    

    The uuid is a Sentry App installation UUID, not something users should see or manage. Resolving it automatically is the core design challenge here.

    There's already a read path: getIssueExternalLinks in the API client hits /organizations/{org}/issues/{id}/external-issues/ and its output already shows up in get_issue_details. This proposal is purely the write side.


    New Parameters on update_issue

    Add four optional params, three of which are required together when linking:

    externalIssueUrl: string       // Full URL of the external issue (e.g. https://linear.app/team/issue/ENG-123)
    externalIssueProject: string   // The external system's project/team/key (e.g. "ENG")
    externalIssueIdentifier: string // Unique ID in the external system (e.g. "ENG-123")
    externalIssueServiceSlug?: string  // Optional disambiguation hint (e.g. "linear", "jira") — only needed when URL inference is ambiguous
    

    The three required-together params map directly to the endpoint body fields. externalIssueServiceSlug is NOT the UUID — it's a user-readable app slug used to disambiguate when multiple integrations might match.

    Combining with existing params should work fine in a single call (e.g. mark resolved AND link to Linear). The issueId integer required by the endpoint is sourced from issue.id on the already-fetched issue object.


    Validation Changes

    The current guard — "at least one of status or assignedTo required" — needs to be extended to also accept external issue linking as a valid action:

    const hasStatusUpdate = status !== undefined;
    const hasAssignmentUpdate = assignedTo !== undefined;
    const hasExternalLink = [externalIssueUrl, externalIssueProject, externalIssueIdentifier].some(Boolean);
    
    if (!hasStatusUpdate && !hasAssignmentUpdate && !hasExternalLink) {
      throw new UserInputError("At least one of ...");
    }
    
    // External fields are all-or-nothing
    if (hasExternalLink) {
      if (!externalIssueUrl || !externalIssueProject || !externalIssueIdentifier) {
        throw new UserInputError(", , and  must all be provided together");
      }
      // Also validate URL is parseable http/https
    }

    UUID Resolution (the interesting part)

    The handler fetches all installations for the org, then resolves to exactly one using URL inference and/or the optional slug hint. It never exposes UUIDs to the user.

    Step 1 — URL-derived service tokens:

    Maintain a small known-host mapping plus hostname label extraction:

    linear.app          → ["linear"]
    *.atlassian.net     → ["jira", "atlassian"]
    github.com          → ["github"]
    gitlab.com          → ["gitlab"]
    bitbucket.org       → ["bitbucket"]
    shortcut.com        → ["shortcut"]
    jira.company.com    → ["jira"]  (leftmost label)
    

    Self-hosted instances (e.g. gitlab.acme.com) are handled by extracting the leftmost hostname label if it matches a known service name.

    Step 2 — Match against installations:

    GET /api/0/organizations/{org}/sentry-app-installations/
    → [{ uuid, app: { slug, name } }, ...]

    Matching is conservative — always prefer exact app.slug match. If externalIssueServiceSlug is provided, use it as the primary filter; URL tokens are the fallback.

    Resolution outcomes:

    • Exactly one match → proceed
    • Zero matches → UserInputError listing installed apps by name/slug (no UUIDs) with instructions to install the integration or pass externalIssueServiceSlug
    • Multiple matches → UserInputError listing the ambiguous app names/slugs with instructions to use externalIssueServiceSlug
    • Multiple matches, same slug → UserInputError saying the ambiguity cannot be resolved without administrative intervention (we will never arbitrarily pick one)

    Critical: installation resolution must happen before any mutation. If resolution fails, neither the PATCH /issues/{id}/ call nor the external issue POST fires.


    API Client Additions

    New schema (in schema.ts):

    export const SentryAppInstallationSchema = z.object({
      uuid: z.string(),
      app: z.object({ slug: z.string(), name: z.string() }).passthrough(),
    }).passthrough();
    
    export const SentryAppInstallationsSchema = z.array(SentryAppInstallationSchema);

    Reuse existing ExternalIssueSchema for the POST response.

    New client methods (in client.ts):

    async listSentryAppInstallations(
      { organizationSlug }: { organizationSlug: string },
      opts?: RequestOptions,
    ): Promise<SentryAppInstallation[]>
    // GET /organizations/{org}/sentry-app-installations/
    
    async createExternalIssueLink(
      { installationUuid, issueId, webUrl, project, identifier }: {
        installationUuid: string;
        issueId: number;
        webUrl: string;
        project: string;
        identifier: string;
      },
      opts?: RequestOptions,
    ): Promise<ExternalIssue>
    // POST /sentry-app-installations/{uuid}/external-issues/

    The installationUuid param on the client method is intentionally kept internal — it never surfaces in the tool layer as a user-facing param.


    Execution Order in Handler

    1. Validate all params
    2. Fetch current issue (already done today)
    3. If external link params present:
       a. Fetch installations → resolve UUID (fail here if ambiguous/missing)
    4. Perform existing issue update if status/assignedTo/ignore needed
    5. POST external issue link if requested
    6. Post reason comment if provided
    7. Return combined output
    

    This means unresolvable linking aborts before any mutation, which is the safe behavior. The failure case for step 5 (link POST fails after update succeeds) must be reported clearly as a partial success — "Issue was updated, but external issue linking failed: " — rather than masking the error or implying full success.


    Output Changes

    Extend the "## Changes Made" section:

    **Linked External Issue**: ENG-123 (linear) → https://linear.app/acme/issue/ENG-123
    

    Uses response fields displayName, serviceType, webUrl. Falls back to externalIssueIdentifier if displayName is absent.


    Mock / Test Coverage Needed

    New mocks (in mcp-server-mocks):

    • GET /api/0/organizations/:org/sentry-app-installations/
    • POST /api/0/sentry-app-installations/:uuid/external-issues/

    Unit tests for update_issue:

    • Link-only (all 3 external params, no status/assignedTo) → succeeds
    • Partial external params → UserInputError
    • externalIssueServiceSlug alone → UserInputError
    • No matching installation → error lists installed apps without UUIDs
    • Multiple matching installations → error lists candidates, no UUID disclosure
    • Combined update + link → updateIssue and createExternalIssueLink both called
    • Install resolution fails → updateIssue NOT called (fail-before-mutate verified)
    • Link POST fails after update → partial success message

    Resolver unit tests (can be a pure function, easy to test in isolation):

    • linear.app → matches linear slug
    • atlassian.net → matches jira slug
    • jira.company.com (self-hosted) → matches jira slug
    • Unknown host → zero match error with available app list
    • Service slug narrows two candidates to one → succeeds
    • Service slug still ambiguous (two installs with same slug) → error

    Out of Scope

    • Deleting/unlinking external issue links
    • Supporting the delete endpoint (DELETE /sentry-app-installations/{uuid}/external-issues/{id}/) — future work

    No New Tool

    This stays in update_issue. No new tool registration needed.

    Action taken on behalf of David Cramer.

  8. added 7 commits that reference this issue on Jun 16, 2026
    eb46060
    6b45140
    a6f4e16
    43b8684
    1133c02
    fc49666
    6897291
  9. added a commit that references this issue on Sep 28, 2026
    0563bde
  10. betegon commented on Sep 28, 2026

    @betegon
    Member

    Hey everyone!

    thanks for your patience, this is finally live! You can now link and unlink existing tickets with link_issue and unlink_issue. Supports Jira, GitHub issues and PRs, Linear, GitLab, Bitbucket, Azure DevOps, and compatible Sentry Apps.

    Give it a try and let us know how it works for you!

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions