Skip to main content
Glama
imrnbeg

Jira MCP Server

by imrnbeg

get_jira_issue_comments

Retrieve paginated comments for a Jira issue to track discussion history and collaboration details. Specify issue key and adjust pagination parameters to access relevant conversation data.

Instructions

Retrieve comments for a Jira issue with pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueIdOrKeyYesIssue key or ID (e.g., PROJ-123)
startAtNoPagination start index (default 0)
maxResultsNoPage size (1-100, default 50)

Implementation Reference

  • The handler function for the 'get_jira_issue_comments' tool. It constructs a URL for the Jira REST API endpoint to fetch comments for the specified issue, handles pagination parameters, fetches the data, processes the comments into a structured format (including id, author, dates, and body), and returns either structured content or an error response.
    async (args: { issueIdOrKey: string; startAt?: number; maxResults?: number }) => {
      try {
        const params = new URLSearchParams();
        if (typeof args.startAt === "number") params.set("startAt", String(args.startAt));
        if (typeof args.maxResults === "number") params.set("maxResults", String(args.maxResults));
        const url = `${JIRA_URL}/rest/api/3/issue/${encodeURIComponent(args.issueIdOrKey)}/comment${params.toString() ? `?${params.toString()}` : ""}`;
        const response = await fetch(url, { method: "GET", headers: getJiraHeaders() });
        if (!response.ok) {
          const errorText = await response.text();
          return { content: [{ type: "text", text: `Failed to get comments for ${args.issueIdOrKey}: ${response.status} ${response.statusText}\n${errorText}` }], isError: true };
        }
        const data = await response.json() as any;
        const comments = (data.comments || []).map((c: any) => ({ id: c.id, author: c.author?.displayName, created: c.created, updated: c.updated, body: typeof c.body === 'string' ? c.body : JSON.stringify(c.body) }));
        return { content: [{ type: "text", text: `Found ${data.total ?? comments.length} comments (showing ${comments.length}).` }], structuredContent: { issueIdOrKey: args.issueIdOrKey, total: data.total ?? comments.length, startAt: data.startAt ?? 0, maxResults: data.maxResults ?? comments.length, comments, raw: data } };
      } catch (error) {
        return { content: [{ type: "text", text: `Error getting comments for ${args.issueIdOrKey}: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
      }
    }
  • Zod input schema defining the parameters for the tool: issueIdOrKey (required string), startAt (optional non-negative integer), maxResults (optional integer between 1-100). Includes descriptions for each.
    inputSchema: {
      issueIdOrKey: z.string().describe("Issue key or ID (e.g., PROJ-123)"),
      startAt: z.number().int().min(0).optional().describe("Pagination start index (default 0)"),
      maxResults: z.number().int().min(1).max(100).optional().describe("Page size (1-100, default 50)"),
    },
  • src/server.ts:309-338 (registration)
    The mcp.registerTool call that registers the 'get_jira_issue_comments' tool, providing the name, metadata (title, description), input schema, and the handler function.
    mcp.registerTool(
      "get_jira_issue_comments",
      {
        title: "Get Jira Issue Comments",
        description: "Retrieve comments for a Jira issue with pagination.",
        inputSchema: {
          issueIdOrKey: z.string().describe("Issue key or ID (e.g., PROJ-123)"),
          startAt: z.number().int().min(0).optional().describe("Pagination start index (default 0)"),
          maxResults: z.number().int().min(1).max(100).optional().describe("Page size (1-100, default 50)"),
        },
      },
      async (args: { issueIdOrKey: string; startAt?: number; maxResults?: number }) => {
        try {
          const params = new URLSearchParams();
          if (typeof args.startAt === "number") params.set("startAt", String(args.startAt));
          if (typeof args.maxResults === "number") params.set("maxResults", String(args.maxResults));
          const url = `${JIRA_URL}/rest/api/3/issue/${encodeURIComponent(args.issueIdOrKey)}/comment${params.toString() ? `?${params.toString()}` : ""}`;
          const response = await fetch(url, { method: "GET", headers: getJiraHeaders() });
          if (!response.ok) {
            const errorText = await response.text();
            return { content: [{ type: "text", text: `Failed to get comments for ${args.issueIdOrKey}: ${response.status} ${response.statusText}\n${errorText}` }], isError: true };
          }
          const data = await response.json() as any;
          const comments = (data.comments || []).map((c: any) => ({ id: c.id, author: c.author?.displayName, created: c.created, updated: c.updated, body: typeof c.body === 'string' ? c.body : JSON.stringify(c.body) }));
          return { content: [{ type: "text", text: `Found ${data.total ?? comments.length} comments (showing ${comments.length}).` }], structuredContent: { issueIdOrKey: args.issueIdOrKey, total: data.total ?? comments.length, startAt: data.startAt ?? 0, maxResults: data.maxResults ?? comments.length, comments, raw: data } };
        } catch (error) {
          return { content: [{ type: "text", text: `Error getting comments for ${args.issueIdOrKey}: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );

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