add_comment
Add comments to Jira issues to provide updates, share information, or document progress on project tasks and bug reports.
Instructions
Add a comment to a Jira issue
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comment | Yes | The comment in ADF format or plain string. Example ADF: {"type":"doc","version":1,"content":[{"type":"paragraph","content":[{"type":"text","text":"Comment text"}]}]} | |
| issueKey | Yes | The issue key to comment on (e.g., PROJ-123) |
Implementation Reference
- src/handlers/comment-handlers.ts:7-64 (handler)The handler function that implements the core logic for the 'add_comment' tool: validates inputs, converts plain text comments to ADF format, posts to Jira API, and returns success/error responses.async handleAddComment(args: any) { try { const { issueKey, comment } = args; if (!issueKey || !comment) { throw new Error('issueKey and comment are required'); } // Handle comment body - convert to ADF format if it's plain text let commentBody; if (typeof comment === 'string') { // Convert plain text to Atlassian Document Format commentBody = { type: 'doc', version: 1, content: [ { type: 'paragraph', content: [ { type: 'text', text: comment, }, ], }, ], }; } else { // Already in ADF format commentBody = comment; } const commentData = { body: commentBody, }; const result = await this.apiClient.post(`/issue/${issueKey}/comment`, commentData); return { content: [ { type: 'text', text: `✅ Comment added to ${issueKey} successfully!\n\n**Comment ID**: ${result.id}`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: JiraFormatters.formatError(error), }, ], isError: true, }; } }
- src/tools/definitions.ts:190-206 (schema)The tool definition including name, description, and input schema for 'add_comment' used for tool listing and validation.{ name: 'add_comment', description: 'Add a comment to a Jira issue', inputSchema: { type: 'object', properties: { issueKey: { type: 'string', description: 'The issue key to comment on (e.g., PROJ-123)', }, comment: { description: 'The comment in ADF format or plain string. Example ADF: {"type":"doc","version":1,"content":[{"type":"paragraph","content":[{"type":"text","text":"Comment text"}]}]}', }, }, required: ['issueKey', 'comment'], }, },
- src/index.ts:122-123 (registration)The switch case that registers and routes 'add_comment' tool calls to the appropriate handler method.case 'add_comment': return this.commentHandlers.handleAddComment(request.params.arguments);