UNPKG

@aashari/mcp-server-atlassian-confluence

Version:

Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP in

81 lines (80 loc) 3.65 kB
"use strict"; /** * Formatter for Confluence comments */ Object.defineProperty(exports, "__esModule", { value: true }); exports.formatCommentsList = formatCommentsList; const formatter_util_js_1 = require("../utils/formatter.util.js"); /** * Format a list of comments for display * * @param commentsData - Raw comments data from the API with pre-converted markdown content * @param pageId - ID of the page the comments belong to * @param baseUrl - Base URL for constructing comment links * @returns Formatted string with comments information in markdown format */ function formatCommentsList(commentsData, pageId, baseUrl = '') { if (!commentsData || commentsData.length === 0) { return ('No comments found for this page.' + '\n\n' + (0, formatter_util_js_1.formatSeparator)() + '\n' + `*Information retrieved at: ${(0, formatter_util_js_1.formatDate)(new Date())}*`); } const lines = [(0, formatter_util_js_1.formatHeading)('Page Comments', 1), '']; // Format each comment with its details const formattedList = (0, formatter_util_js_1.formatNumberedList)(commentsData, (comment, _index) => { const itemLines = []; // Basic information const title = comment.title.replace(/^Re: /, ''); itemLines.push((0, formatter_util_js_1.formatHeading)(title, 3)); // Add inline comment indicator if applicable if (comment.extensions?.location === 'inline') { itemLines.push('**📌 Inline Comment**'); // Add the highlighted text as a blockquote if available if (comment.highlightedText) { itemLines.push(''); // Format the highlighted text as a blockquote const lines = comment.highlightedText.split('\n'); for (const line of lines) { itemLines.push(`> ${line}`); } itemLines.push(''); } } // Comment metadata const properties = { ID: comment.id, Status: comment.status, Type: comment.extensions?.location === 'inline' ? 'Inline Comment' : 'Page Comment', Created: comment._links?.self ? (0, formatter_util_js_1.formatDate)(new Date()) : 'N/A', // We don't have creation date in the response }; // Format as a bullet list itemLines.push((0, formatter_util_js_1.formatBulletList)(properties, (key) => key)); // Comment content itemLines.push((0, formatter_util_js_1.formatHeading)('Content', 4)); // Use the pre-converted markdown content itemLines.push(comment.convertedMarkdownBody || '*No content available*'); // Add link to the comment if available if (comment._links?.webui) { const commentUrl = comment._links.webui.startsWith('http') ? comment._links.webui : `${baseUrl}${comment._links.webui}`; itemLines.push(''); itemLines.push(`[View comment in Confluence](${commentUrl})`); } return itemLines.join('\n'); }); lines.push(formattedList); // Add standard footer with timestamp lines.push('\n\n' + (0, formatter_util_js_1.formatSeparator)()); lines.push(`*Information retrieved at: ${(0, formatter_util_js_1.formatDate)(new Date())}*`); // Add link to the page if (baseUrl && pageId) { const pageUrl = `${baseUrl}/pages/viewpage.action?pageId=${pageId}`; lines.push(`*View all comments on [this page](${pageUrl})*`); } return lines.join('\n'); }