jira_get_comments
Retrieve all comments from a Jira issue, including author, content, timestamps, and visibility settings. Supports pagination for issues with many comments.
Instructions
Retrieves all comments for a Jira issue. Returns comment author, content, timestamps, and visibility settings. Supports pagination for issues with many comments.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueKey | Yes | Issue key to get comments for (e.g., PROJECT-123) | |
| maxResults | No | Maximum number of comments to return (default: 50) | |
| orderBy | No | Sort order for comments: "created" (oldest first), "-created" (newest first) | |
| startAt | No | Index of first comment to return (for pagination) |
Implementation Reference
- src/tools/get-comments.ts:46-79 (handler)The handler function that executes the 'jira_get_comments' tool logic. It validates the input, calls the API helper, and formats the response.
export async function handleGetComments(input: unknown): Promise<McpToolResponse> { try { const validated = validateInput(GetCommentsInputSchema, input); log.info(`Getting comments for issue ${validated.issueKey}...`); const options: { maxResults?: number; orderBy?: string; startAt?: number; } = {}; if (validated.maxResults !== undefined) { options.maxResults = validated.maxResults; } if (validated.orderBy !== undefined) { options.orderBy = validated.orderBy; } if (validated.startAt !== undefined) { options.startAt = validated.startAt; } const comments = await getComments(validated.issueKey, options); log.info(`Retrieved ${comments.comments.length} comment(s) for ${validated.issueKey}`); return formatCommentsResponse(comments, validated.issueKey); } catch (error) { log.error('Error in handleGetComments:', error); return handleError(error); } } - src/types/tools.ts:283-305 (schema)Zod schema and TypeScript type for validating the input to 'jira_get_comments'. Accepts issueKey (required), maxResults, orderBy, and startAt.
export const GetCommentsInputSchema = z.object({ issueKey: z .string() .describe('Issue key to get comments for (e.g., PROJECT-123)') .refine((v) => isValidIssueKey(v), 'Invalid issue key format'), maxResults: z .number() .min(1) .max(100) .optional() .describe('Maximum number of comments to return (default: 50)'), orderBy: z .enum(['created', '-created', '+created']) .optional() .describe('Sort order for comments: "created" (oldest first), "-created" (newest first)'), startAt: z .number() .min(0) .optional() .describe('Index of first comment to return (for pagination)'), }); export type GetCommentsInput = z.infer<typeof GetCommentsInputSchema>; - src/index.ts:144-149 (registration)Registration of 'jira_get_comments' tool on the MCP server, mapping the tool name to its description, input schema, and handler.
name: TOOL_NAMES.GET_COMMENTS, description: tools.getCommentsTool.description!, inputSchema: GetCommentsInputSchema, handler: tools.handleGetComments, annotations: { readOnlyHint: true }, }, - src/tools/get-comments.ts:13-44 (registration)Tool definition object with name (from TOOL_NAMES.GET_COMMENTS), description, and input schema used for registration.
export const getCommentsTool: Tool = { name: TOOL_NAMES.GET_COMMENTS, description: 'Retrieves all comments for a Jira issue. Returns comment author, content, timestamps, and visibility settings. Supports pagination for issues with many comments.', inputSchema: { type: 'object', properties: { issueKey: { type: 'string', description: 'Issue key to get comments for (e.g., PROJECT-123)', }, maxResults: { type: 'number', description: 'Maximum number of comments to return (default: 50, max: 100)', minimum: 1, maximum: 100, }, orderBy: { type: 'string', enum: ['created', '-created', '+created'], description: 'Sort order for comments: "created" or "+created" (oldest first), "-created" (newest first)', }, startAt: { type: 'number', description: 'Index of first comment to return (for pagination, default: 0)', minimum: 0, }, }, required: ['issueKey'], }, }; - src/utils/api-helpers.ts:581-610 (helper)The API helper function that makes the actual Jira REST API call to GET /rest/api/3/issue/{issueKey}/comment to retrieve comments.
export async function getComments( issueKey: string, options: { maxResults?: number; orderBy?: string; startAt?: number; } = {} ): Promise<JiraCommentsResponse> { const params: Record<string, any> = {}; if (options.maxResults !== undefined) { params.maxResults = options.maxResults; } if (options.orderBy !== undefined) { params.orderBy = options.orderBy; } if (options.startAt !== undefined) { params.startAt = options.startAt; } const config: AxiosRequestConfig = { method: 'GET', url: `/issue/${issueKey}/comment`, params, }; return await makeJiraRequest<JiraCommentsResponse>(config); }