UNPKG

@aashari/mcp-server-atlassian-jira

Version:

Node.js/TypeScript MCP server for Atlassian Jira. Equips AI systems (LLMs) with tools to list/get projects, search/get issues (using JQL/ID), and view dev info (commits, PRs). Connects AI capabilities directly into Jira project management and issue tracki

96 lines (95 loc) 4.79 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const logger_util_js_1 = require("../utils/logger.util.js"); const error_util_js_1 = require("../utils/error.util.js"); const atlassian_comments_types_js_1 = require("./atlassian.comments.types.js"); const atlassian_comments_controller_js_1 = __importDefault(require("../controllers/atlassian.comments.controller.js")); // Create a contextualized logger for this file const toolLogger = logger_util_js_1.Logger.forContext('tools/atlassian.comments.tool.ts'); // Log tool module initialization toolLogger.debug('Jira comments tool module initialized'); /** * MCP Tool: List Comments for a Jira Issue * * Lists comments for a specific Jira issue. * Returns a formatted markdown response with comment details. * * @param {ListCommentsToolArgsType} args - Tool arguments for listing comments * @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted comments list * @throws Will return error message if comment listing fails */ async function listComments(args) { const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.comments.tool.ts', 'listComments'); methodLogger.debug('Listing Jira comments with args:', args); try { const result = await atlassian_comments_controller_js_1.default.listComments(args); methodLogger.debug('Successfully retrieved comments list'); // Content already includes the pagination information return { content: [ { type: 'text', text: result.content, }, ], }; } catch (error) { methodLogger.error('Failed to list comments', error); return (0, error_util_js_1.formatErrorForMcpTool)(error); } } /** * MCP Tool: Add Comment to a Jira Issue * * Adds a new comment to a specific Jira issue. * Returns a formatted markdown response confirming the addition. * * @param {AddCommentToolArgsType} args - Tool arguments for adding a comment * @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with confirmation * @throws Will return error message if comment addition fails */ async function addComment(args) { const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.comments.tool.ts', 'addComment'); methodLogger.debug('Adding comment to Jira issue:', { issueIdOrKey: args.issueIdOrKey, bodyLength: args.commentBody?.length || 0, }); try { const result = await atlassian_comments_controller_js_1.default.addComment(args); methodLogger.debug('Successfully added comment'); return { content: [ { type: 'text', text: result.content, }, ], }; } catch (error) { methodLogger.error('Failed to add comment', error); return (0, error_util_js_1.formatErrorForMcpTool)(error); } } /** * Register Atlassian Comments MCP Tools * * Registers the list-comments and add-comment tools with the MCP server. * Each tool is registered with its schema, description, and handler function. * * @param {McpServer} server - The MCP server instance to register tools with */ function registerTools(server) { const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.comments.tool.ts', 'registerTools'); methodLogger.debug('Registering Atlassian Comments tools...'); // Register the list comments tool server.tool('jira_ls_comments', `Lists comments for a specific Jira issue identified by \`issueIdOrKey\`. Supports pagination via \`limit\` and \`startAt\`. Returns a formatted Markdown list of comments with author, date, and content. Pagination information including next page instructions is included in the returned text. Requires Jira credentials to be configured.`, atlassian_comments_types_js_1.ListCommentsToolArgs.shape, listComments); // Register the add comment tool server.tool('jira_add_comment', `Adds a new comment to a specific Jira issue identified by \`issueIdOrKey\`. The content of the comment is provided in \`commentBody\` and supports Markdown formatting which will be converted to Jira's Atlassian Document Format (ADF). Returns a confirmation message and link to the newly created comment. Requires Jira credentials to be configured.`, atlassian_comments_types_js_1.AddCommentToolArgs.shape, addComment); methodLogger.debug('Successfully registered Atlassian Comments tools'); } exports.default = { registerTools };