Skip to main content
Glama

add_comment

Add comments to Jira issues to provide updates, share information, or document progress on tasks and projects.

Instructions

Add a comment to a specified Jira issue

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueKeyYesThe issue key (e.g., "PROJ-123")
commentBodyYesThe comment text to add

Implementation Reference

  • MCP tool handler for "add_comment" that validates inputs, calls the addComment helper from jira-client, handles errors, and returns structured output.
    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, }; }
  • Zod schema definitions for input (issueKey, commentBody) and output (success, commentId, created, error) of 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)
    Registration of the "add_comment" MCP tool with McpServer, including name, schema, and handler reference.
    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, }; } } );
  • Supporting helper function that performs the actual Jira REST API POST request to /issue/{issueKey}/comment, converting plain text commentBody to ADF format and 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, }; }

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/eh24905-wiz/jira-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server