add_comment
Add comments to Jira issues to document updates, provide context, or communicate with team members about task progress.
Instructions
Add a comment to a specified Jira issue
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueKey | Yes | The issue key (e.g., "PROJ-123") | |
| commentBody | Yes | The comment text to add |
Implementation Reference
- src/jira-client.ts:369-398 (handler)Core handler function that executes the Jira API POST request to add a comment to the specified issue, returning the new comment ID and creation timestamp.export async function addComment(issueKey: string, commentBody: string): Promise<{ id: string; created: string }> { const response = await jiraFetch<{ id: string; created: string; }>(`/issue/${issueKey}/comment`, { method: 'POST', body: JSON.stringify({ body: { type: 'doc', version: 1, content: [ { type: 'paragraph', content: [ { type: 'text', text: commentBody, }, ], }, ], }, }), }); return { id: response.id, created: response.created, }; }
- src/index.ts:119-136 (schema)Zod schema defining input (issueKey, commentBody) and output (success, commentId, created, error) validation for the add_comment tool.{ title: 'Add Comment', description: 'Add a comment to a specified Jira issue', inputSchema: { issueKey: z.string().describe('The issue key (e.g., "PROJ-123")'), commentBody: z.string().describe('The comment text to add'), }, outputSchema: { success: z.boolean(), commentId: z.string().optional(), created: z.string().optional(), error: z.object({ message: z.string(), statusCode: z.number().optional(), details: z.unknown().optional(), }).optional(), }, },
- src/index.ts:117-165 (registration)MCP server registration of the 'add_comment' tool, including schema, validation, error handling, and delegation to the core addComment function.server.registerTool( 'add_comment', { title: 'Add Comment', description: 'Add a comment to a specified Jira issue', inputSchema: { issueKey: z.string().describe('The issue key (e.g., "PROJ-123")'), commentBody: z.string().describe('The comment text to add'), }, outputSchema: { success: z.boolean(), commentId: z.string().optional(), created: z.string().optional(), error: z.object({ message: z.string(), statusCode: z.number().optional(), details: z.unknown().optional(), }).optional(), }, }, async ({ issueKey, commentBody }) => { try { if (!issueKey || !issueKey.trim()) { throw new Error('issueKey is required'); } if (!commentBody || !commentBody.trim()) { throw new Error('commentBody is required'); } const result = await addComment(issueKey, commentBody); const output = { success: true, commentId: result.id, created: result.created, }; return { content: [{ type: 'text', text: JSON.stringify(output, null, 2) }], structuredContent: output, }; } catch (error) { const output = { success: false, ...formatError(error) }; return { content: [{ type: 'text', text: JSON.stringify(output, null, 2) }], structuredContent: output, isError: true, }; } } );