Skip to main content
Glama
kornbed

Jira MCP Server for Cursor

by kornbed

get_ticket

Retrieve details for a specific Jira ticket by entering its ID to view status, description, and other information directly within your editor.

Instructions

Get details of a specific Jira ticket

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ticketIdYesThe Jira ticket ID (e.g., PROJECT-123)

Implementation Reference

  • The main handler function for the 'get_ticket' tool. It validates configuration, fetches the ticket details from Jira API including summary, status, type, description (parsed from ADF), parent, and linked issues, then formats and returns them.
    async ({ ticketId }: { ticketId: string }) => {
      const configError = validateJiraConfig();
      if (configError) {
        return {
          content: [{ type: "text", text: `Configuration error: ${configError}` }],
        };
      }
    
      try {
        const ticket = await jira.issues.getIssue({
          issueIdOrKey: ticketId,
          fields: ['summary', 'status', 'issuetype', 'description', 'parent', 'issuelinks'],
        });
    
        const formattedTicket = [
          `Key: ${ticket.key}`,
          `Summary: ${ticket.fields?.summary || 'No summary'}`,
          `Status: ${ticket.fields?.status?.name || 'Unknown status'}`,
          `Type: ${ticket.fields?.issuetype?.name || 'Unknown type'}`,
          `Description:\n${extractTextFromADF(ticket.fields?.description) || 'No description'}`,
          `Parent: ${ticket.fields?.parent?.key || 'No parent'}`
        ];
    
        // Linked Issues Section
        const links = ticket.fields?.issuelinks || [];
        if (Array.isArray(links) && links.length > 0) {
          formattedTicket.push('\nLinked Issues:');
          for (const link of links) {
            // Outward (this issue is the source)
            if (link.outwardIssue) {
              const key = link.outwardIssue.key;
              const summary = link.outwardIssue.fields?.summary || 'No summary';
              const type = link.type?.outward || link.type?.name || 'Related';
              formattedTicket.push(`- [${type}] ${key}: ${summary}`);
            }
            // Inward (this issue is the target)
            if (link.inwardIssue) {
              const key = link.inwardIssue.key;
              const summary = link.inwardIssue.fields?.summary || 'No summary';
              const type = link.type?.inward || link.type?.name || 'Related';
              formattedTicket.push(`- [${type}] ${key}: ${summary}`);
            }
          }
        } else {
          formattedTicket.push('\nLinked Issues: None');
        }
    
        return {
          content: [{ type: "text", text: formattedTicket.join('\n') }],
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to fetch ticket: ${(error as Error).message}` }],
        };
      }
    }
  • Input schema for the 'get_ticket' tool, using Zod to validate the 'ticketId' parameter.
    {
      ticketId: z.string().describe("The Jira ticket ID (e.g., PROJECT-123)"),
    },
  • src/server.ts:159-221 (registration)
    Registration of the 'get_ticket' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool(
      "get_ticket",
      "Get details of a specific Jira ticket",
      {
        ticketId: z.string().describe("The Jira ticket ID (e.g., PROJECT-123)"),
      },
      async ({ ticketId }: { ticketId: string }) => {
        const configError = validateJiraConfig();
        if (configError) {
          return {
            content: [{ type: "text", text: `Configuration error: ${configError}` }],
          };
        }
    
        try {
          const ticket = await jira.issues.getIssue({
            issueIdOrKey: ticketId,
            fields: ['summary', 'status', 'issuetype', 'description', 'parent', 'issuelinks'],
          });
    
          const formattedTicket = [
            `Key: ${ticket.key}`,
            `Summary: ${ticket.fields?.summary || 'No summary'}`,
            `Status: ${ticket.fields?.status?.name || 'Unknown status'}`,
            `Type: ${ticket.fields?.issuetype?.name || 'Unknown type'}`,
            `Description:\n${extractTextFromADF(ticket.fields?.description) || 'No description'}`,
            `Parent: ${ticket.fields?.parent?.key || 'No parent'}`
          ];
    
          // Linked Issues Section
          const links = ticket.fields?.issuelinks || [];
          if (Array.isArray(links) && links.length > 0) {
            formattedTicket.push('\nLinked Issues:');
            for (const link of links) {
              // Outward (this issue is the source)
              if (link.outwardIssue) {
                const key = link.outwardIssue.key;
                const summary = link.outwardIssue.fields?.summary || 'No summary';
                const type = link.type?.outward || link.type?.name || 'Related';
                formattedTicket.push(`- [${type}] ${key}: ${summary}`);
              }
              // Inward (this issue is the target)
              if (link.inwardIssue) {
                const key = link.inwardIssue.key;
                const summary = link.inwardIssue.fields?.summary || 'No summary';
                const type = link.type?.inward || link.type?.name || 'Related';
                formattedTicket.push(`- [${type}] ${key}: ${summary}`);
              }
            }
          } else {
            formattedTicket.push('\nLinked Issues: None');
          }
    
          return {
            content: [{ type: "text", text: formattedTicket.join('\n') }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Failed to fetch ticket: ${(error as Error).message}` }],
          };
        }
      }
    );
  • Helper function to recursively extract plain text from Jira's ADF (Atlassian Document Format) used in 'get_ticket' to parse ticket description and linked issue summaries.
    function extractTextFromADF(node: any): string {
      if (!node) {
        return '';
      }
    
      // Handle text nodes directly
      if (node.type === 'text' && node.text) {
        return node.text;
      }
    
      let text = '';
      // Handle block nodes like paragraph, heading, etc.
      if (node.content && Array.isArray(node.content)) {
        text = node.content.map(extractTextFromADF).join('');
        // Add a newline after paragraphs for better formatting
        if (node.type === 'paragraph') {
          text += '\n';
        }
      }
    
      return text;
    }
  • Helper function to validate required Jira environment variables, called at the start of the 'get_ticket' handler.
    function validateJiraConfig(): string | null {
      if (!process.env.JIRA_HOST) return "JIRA_HOST environment variable is not set";
      if (!process.env.JIRA_EMAIL) return "JIRA_EMAIL environment variable is not set";
      if (!process.env.JIRA_API_TOKEN) return "JIRA_API_TOKEN environment variable is not set";
      return null;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must disclose behavioral traits. It only says 'get details' without specifying what data is returned (e.g., full issue object, including comments, attachments), authentication needs, or any side effects. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise, one sentence. No unnecessary words. However, the brevity sacrifices valuable context that could be added without bloating.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one simple parameter and no output schema, the description is complete on a surface level but fails to provide necessary context such as expected output structure or how to handle errors. Lacks depth compared to complexity of Jira API.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter ticketId, which is well-described with format example. The description adds no additional meaning beyond the schema, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description 'Get details of a specific Jira ticket' clearly states the action (get) and resource (ticket). It is specific enough to distinguish from create or update tools, but lacks differentiation from closely related siblings like get_ticket_fields or get_comments.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives such as list_tickets or search_tickets. The description does not mention scenarios where retrieving a single ticket's details is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.