add_comment
Add comments to JIRA issues to provide updates, clarify requirements, or document progress within project workflows.
Instructions
Add a comment to a JIRA issue
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueIdOrKey | Yes | The ID or key of the issue to add the comment to | |
| body | Yes | The content of the comment (plain text) |
Implementation Reference
- src/index.ts:454-474 (handler)Primary MCP tool handler for 'add_comment'. Validates input (issueIdOrKey, body) and delegates to JiraApiService.addCommentToIssue, returning JSON response.case "add_comment": { if ( !args.issueIdOrKey || typeof args.issueIdOrKey !== "string" || !args.body || typeof args.body !== "string" ) { throw new McpError( ErrorCode.InvalidParams, "issueIdOrKey and body are required", ); } const response = await this.jiraApi.addCommentToIssue( args.issueIdOrKey, args.body, ); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) }, ], };
- src/services/jira-api.ts:526-551 (handler)Core implementation that converts plain text to ADF, POSTs to JIRA API to add comment, and returns cleaned response.async addCommentToIssue( issueIdOrKey: string, body: string ): Promise<AddCommentResponse> { const adfBody = this.createAdfFromBody(body); const payload = { body: adfBody, }; const response = await this.fetchJson<JiraCommentResponse>( `/rest/api/3/issue/${issueIdOrKey}/comment`, { method: "POST", body: JSON.stringify(payload), } ); return { id: response.id, author: response.author.displayName, created: response.created, updated: response.updated, body: this.extractTextContent(response.body.content), }; }
- src/index.ts:246-264 (registration)Tool registration in MCP server's listTools handler, defining name, description, and input schema.{ name: "add_comment", description: "Add a comment to a JIRA issue", inputSchema: { type: "object", properties: { issueIdOrKey: { type: "string", description: "The ID or key of the issue to add the comment to", }, body: { type: "string", description: "The content of the comment (plain text)", }, }, required: ["issueIdOrKey", "body"], additionalProperties: false, }, },
- src/types/jira.ts:79-85 (schema)TypeScript interface defining the structure of the response from addCommentToIssue.export interface AddCommentResponse { id: string; author: string; created: string; updated: string; body: string; // Return plain text for simplicity }
- src/services/jira-api.ts:505-520 (helper)Helper to convert plain text comment to ADF format required by JIRA API.private createAdfFromBody(text: string): AdfDoc { return { version: 1, type: "doc", content: [ { type: "paragraph", content: [ { type: "text", text: text, }, ], }, ], };