Skip to main content
Glama
kornbed

Jira MCP Server for Cursor

get_comments

Retrieve comments for a Jira ticket to track discussions and updates directly within your editor.

Instructions

Get comments for a specific Jira ticket

Input Schema

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

Implementation Reference

  • The handler function for the 'get_comments' tool. It validates Jira configuration, fetches comments using the Jira API, formats them with author, date, and extracted text body using the extractTextFromADF helper, and handles errors including 404 for non-existent tickets.
    async ({ ticketId }: { ticketId: string }) => {
      const configError = validateJiraConfig();
      if (configError) {
        return {
          content: [{ type: "text", text: `Configuration error: ${configError}` }],
        };
      }
    
      try {
        const commentsResult = await jira.issueComments.getComments({ issueIdOrKey: ticketId });
        
        if (!commentsResult.comments || commentsResult.comments.length === 0) {
          return {
            content: [{ type: "text", text: "No comments found for this ticket." }],
          };
        }
    
        const formattedComments = commentsResult.comments.map(comment => {
          const author = comment.author?.displayName || 'Unknown Author';
          // Comments also use ADF, so we need to parse them
          const body = extractTextFromADF(comment.body) || 'No comment body'; 
          const createdDate = comment.created ? new Date(comment.created).toLocaleString() : 'Unknown date';
          return `[${createdDate}] ${author}:\n${body.trim()}\n---`; // Added trim() and separator
        }).join('\n\n'); // Separate comments with double newline
    
        return {
          content: [{ type: "text", text: formattedComments }],
        };
      } catch (error) {
        // Handle cases where the ticket might not exist or other API errors
        if ((error as any).response?.status === 404) {
            return {
                content: [{ type: "text", text: `Ticket ${ticketId} not found.` }],
            };
        }
        return {
          content: [{ type: "text", text: `Failed to fetch comments: ${(error as Error).message}` }],
        };
      }
    }
  • Input schema for the 'get_comments' tool, defining the required 'ticketId' parameter as a string with description.
    {
      ticketId: z.string().describe("The Jira ticket ID (e.g., PROJECT-123)"),
    },
  • src/server.ts:223-269 (registration)
    Registration of the 'get_comments' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      "get_comments",
      "Get comments for 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 commentsResult = await jira.issueComments.getComments({ issueIdOrKey: ticketId });
          
          if (!commentsResult.comments || commentsResult.comments.length === 0) {
            return {
              content: [{ type: "text", text: "No comments found for this ticket." }],
            };
          }
    
          const formattedComments = commentsResult.comments.map(comment => {
            const author = comment.author?.displayName || 'Unknown Author';
            // Comments also use ADF, so we need to parse them
            const body = extractTextFromADF(comment.body) || 'No comment body'; 
            const createdDate = comment.created ? new Date(comment.created).toLocaleString() : 'Unknown date';
            return `[${createdDate}] ${author}:\n${body.trim()}\n---`; // Added trim() and separator
          }).join('\n\n'); // Separate comments with double newline
    
          return {
            content: [{ type: "text", text: formattedComments }],
          };
        } catch (error) {
          // Handle cases where the ticket might not exist or other API errors
          if ((error as any).response?.status === 404) {
              return {
                  content: [{ type: "text", text: `Ticket ${ticketId} not found.` }],
              };
          }
          return {
            content: [{ type: "text", text: `Failed to fetch comments: ${(error as Error).message}` }],
          };
        }
      }
    );
  • Helper function to recursively extract plain text from Jira's ADF (Atlassian Document Format) structures, used to parse comment bodies in the handler.
    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;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states a read operation ('Get'), implying it's likely non-destructive, but doesn't cover aspects like authentication needs, rate limits, error handling, or return format (e.g., comment list structure). For a tool with zero annotation coverage, this is a significant gap.

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

Conciseness5/5

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

The description is a single, clear sentence with zero wasted words. It's front-loaded with the core purpose, making it highly efficient and easy to parse for an agent.

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 the lack of annotations and output schema, the description is incomplete for a tool that likely returns structured data (comments). It doesn't explain what the output contains (e.g., comment text, authors, timestamps) or behavioral traits like pagination. For a read operation with no structured support, more context is needed.

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?

The schema description coverage is 100%, with the single parameter 'ticketId' fully documented in the schema. The description doesn't add any parameter-specific details beyond implying the tool fetches comments for that ticket. This meets the baseline of 3 when the schema does the heavy lifting.

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?

The description clearly states the verb ('Get') and resource ('comments for a specific Jira ticket'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from siblings like 'get_ticket' or 'add_comment' beyond the resource focus, which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid ticket ID), exclusions, or comparisons to siblings like 'get_ticket' (which might include comments) or 'add_comment' (for writing). This leaves the agent without contextual usage cues.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kornbed/jira-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server