Skip to main content
Glama
imrnbeg

Jira MCP Server

by imrnbeg

get_jira_issue

Retrieve detailed Jira issue information by entering its key. Access status, assignee, priority, and descriptions in structured formats for project tracking.

Instructions

Get detailed information about a Jira issue by its key (e.g., PROJ-123)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueKeyYesThe Jira issue key (e.g., PROJ-123, TASK-456)

Implementation Reference

  • The handler function for the 'get_jira_issue' tool. Fetches the Jira issue using the REST API, parses key fields (summary, status, assignee, etc.), cleans the description, and returns formatted text content along with structured data including a URL to the issue.
      async (args: { issueKey: string }) => {
        try {
          const url = `${JIRA_URL}/rest/api/3/issue/${args.issueKey}`;
          const response = await fetch(url, {
            method: "GET",
            headers: getJiraHeaders(),
          });
    
          if (!response.ok) {
            const errorText = await response.text();
            return {
              content: [
                {
                  type: "text",
                  text: `Failed to fetch Jira issue ${args.issueKey}: ${response.status} ${response.statusText}\n${errorText}`,
                },
              ],
              isError: true,
            };
          }
    
          const issueData = await response.json() as any;
          
          // Extract key information from the issue
          const issue = issueData;
          const fields = issue.fields;
          
          const summary = fields.summary || 'No summary';
          const description = fields.description || 'No description';
          const status = fields.status?.name || 'Unknown status';
          const assignee = fields.assignee?.displayName || 'Unassigned';
          const reporter = fields.reporter?.displayName || 'Unknown reporter';
          const priority = fields.priority?.name || 'No priority';
          const issueType = fields.issuetype?.name || 'Unknown type';
          const created = fields.created ? new Date(fields.created).toLocaleDateString() : 'Unknown';
          const updated = fields.updated ? new Date(fields.updated).toLocaleDateString() : 'Unknown';
          
          // Format description (remove HTML tags if present)
          const cleanDescription = typeof description === 'string' 
            ? description.replace(/<[^>]*>/g, '').trim()
            : JSON.stringify(description);
    
          return {
            content: [
              {
                type: "text",
                text: `**${issue.key}: ${summary}**
    
    **Status:** ${status}
    **Type:** ${issueType}
    **Priority:** ${priority}
    **Assignee:** ${assignee}
    **Reporter:** ${reporter}
    **Created:** ${created}
    **Updated:** ${updated}
    
    **Description:**
    ${cleanDescription}
    
    **Full Issue Data:** Available in structured content below.`,
              },
            ],
            structuredContent: {
              issueKey: issue.key,
              summary,
              description: cleanDescription,
              status,
              issueType,
              priority,
              assignee,
              reporter,
              created,
              updated,
              url: `${JIRA_URL}/browse/${issue.key}`,
              fullData: issueData,
            },
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error fetching Jira issue ${args.issueKey}: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
  • Schema definition for the 'get_jira_issue' tool, including title, description, and input schema requiring 'issueKey' as a string.
    {
      title: "Get Jira Issue",
      description: "Get detailed information about a Jira issue by its key (e.g., PROJ-123)",
      inputSchema: {
        issueKey: z.string().describe("The Jira issue key (e.g., PROJ-123, TASK-456)"),
      },
  • src/server.ts:47-145 (registration)
    Registration of the 'get_jira_issue' tool with the MCP server using mcp.registerTool, passing the tool name, schema, and inline handler function.
    mcp.registerTool(
      "get_jira_issue",
      {
        title: "Get Jira Issue",
        description: "Get detailed information about a Jira issue by its key (e.g., PROJ-123)",
        inputSchema: {
          issueKey: z.string().describe("The Jira issue key (e.g., PROJ-123, TASK-456)"),
        },
      },
      async (args: { issueKey: string }) => {
        try {
          const url = `${JIRA_URL}/rest/api/3/issue/${args.issueKey}`;
          const response = await fetch(url, {
            method: "GET",
            headers: getJiraHeaders(),
          });
    
          if (!response.ok) {
            const errorText = await response.text();
            return {
              content: [
                {
                  type: "text",
                  text: `Failed to fetch Jira issue ${args.issueKey}: ${response.status} ${response.statusText}\n${errorText}`,
                },
              ],
              isError: true,
            };
          }
    
          const issueData = await response.json() as any;
          
          // Extract key information from the issue
          const issue = issueData;
          const fields = issue.fields;
          
          const summary = fields.summary || 'No summary';
          const description = fields.description || 'No description';
          const status = fields.status?.name || 'Unknown status';
          const assignee = fields.assignee?.displayName || 'Unassigned';
          const reporter = fields.reporter?.displayName || 'Unknown reporter';
          const priority = fields.priority?.name || 'No priority';
          const issueType = fields.issuetype?.name || 'Unknown type';
          const created = fields.created ? new Date(fields.created).toLocaleDateString() : 'Unknown';
          const updated = fields.updated ? new Date(fields.updated).toLocaleDateString() : 'Unknown';
          
          // Format description (remove HTML tags if present)
          const cleanDescription = typeof description === 'string' 
            ? description.replace(/<[^>]*>/g, '').trim()
            : JSON.stringify(description);
    
          return {
            content: [
              {
                type: "text",
                text: `**${issue.key}: ${summary}**
    
    **Status:** ${status}
    **Type:** ${issueType}
    **Priority:** ${priority}
    **Assignee:** ${assignee}
    **Reporter:** ${reporter}
    **Created:** ${created}
    **Updated:** ${updated}
    
    **Description:**
    ${cleanDescription}
    
    **Full Issue Data:** Available in structured content below.`,
              },
            ],
            structuredContent: {
              issueKey: issue.key,
              summary,
              description: cleanDescription,
              status,
              issueType,
              priority,
              assignee,
              reporter,
              created,
              updated,
              url: `${JIRA_URL}/browse/${issue.key}`,
              fullData: issueData,
            },
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error fetching Jira issue ${args.issueKey}: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Helper function getJiraHeaders() that creates authentication headers for Jira API requests, used in the get_jira_issue handler and other tools.
    function getJiraHeaders(): Record<string, string> {
      const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_API_TOKEN}`).toString('base64');
      return {
        'Authorization': `Basic ${auth}`,
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      };
    }

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/imrnbeg/jira-mcp'

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