@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
99 lines (98 loc) • 5.12 kB
JavaScript
;
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_issues_types_js_1 = require("./atlassian.issues.types.js");
const atlassian_issues_controller_js_1 = __importDefault(require("../controllers/atlassian.issues.controller.js"));
// Create a contextualized logger for this file
const toolLogger = logger_util_js_1.Logger.forContext('tools/atlassian.issues.tool.ts');
// Log tool module initialization
toolLogger.debug('Jira issues tool module initialized');
/**
* MCP Tool: List Jira Issues
*
* Lists Jira issues with optional filtering by JQL query, fields, and limit.
* Returns a formatted markdown response with issue details and pagination info.
*
* @param {ListIssuesToolArgsType} args - Tool arguments for filtering issues
* @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted issues list
* @throws Will return error message if issue listing fails
*/
async function listIssues(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.issues.tool.ts', 'listIssues');
methodLogger.debug('Listing Jira issues with filters:', args);
try {
// Pass the options to the controller
const message = await atlassian_issues_controller_js_1.default.list({
jql: args.jql,
limit: args.limit,
cursor: args.cursor,
});
methodLogger.debug('Successfully retrieved issues from controller');
return {
content: [
{
type: 'text',
text: message.content,
},
],
};
}
catch (error) {
methodLogger.error('Failed to list issues', error);
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* MCP Tool: Get Jira Issue Details
*
* Retrieves detailed information about a specific Jira issue.
* Returns a formatted markdown response with issue data.
*
* @param {GetIssueToolArgsType} args - Tool arguments containing the issue ID/key
* @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted issue details
* @throws Will return error message if issue retrieval fails
*/
async function getIssue(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.issues.tool.ts', 'getIssue');
methodLogger.debug(`Retrieving issue details for ID/key: ${args.issueIdOrKey}`);
try {
const message = await atlassian_issues_controller_js_1.default.get({
issueIdOrKey: args.issueIdOrKey,
});
methodLogger.debug('Successfully retrieved issue details from controller');
return {
content: [
{
type: 'text',
text: message.content,
},
],
};
}
catch (error) {
methodLogger.error('Failed to get issue details', error);
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* Register Atlassian Issues MCP Tools
*
* Registers the list-issues and get-issue 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.issues.tool.ts', 'registerTools');
methodLogger.debug('Registering Atlassian Issues tools...');
// Register the list issues tool
server.tool('jira_list_issues', `Searches for Jira issues using a JQL query (\`jql\`),\n\twith pagination support (\`limit\`, \`cursor\`).\n\n- Use this to find issues matching specific criteria (project, status, assignee, text, etc.).\n- Provides issue keys/IDs needed for \`jira_get_issue\`.\nReturns a formatted list of matching issues including key, summary, type, status, priority, project, and dates.\n**Note:** Requires valid JQL syntax. See Jira documentation for JQL details. Default sort is by last updated.`, atlassian_issues_types_js_1.ListIssuesToolArgs.shape, listIssues);
// Register the get issue details tool
server.tool('jira_get_issue', `Retrieves comprehensive details for a specific Jira issue using its key or ID (\`issueIdOrKey\`).\n- Includes full description (Markdown), status, priority, assignee, reporter, comments (Markdown), attachments, and linked issues.\n- Also fetches linked development information (commits, branches, PRs) if available.\nUse this after finding an issue key/ID to get its complete context.\nReturns detailed issue information formatted as Markdown.`, atlassian_issues_types_js_1.GetIssueToolArgs.shape, getIssue);
methodLogger.debug('Successfully registered Atlassian Issues tools');
}
exports.default = { registerTools };