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

65 lines (64 loc) 3.49 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_search_controller_js_1 = __importDefault(require("../controllers/atlassian.search.controller.js")); const atlassian_search_types_js_1 = require("./atlassian.search.types.js"); /** * MCP Tool: Search Confluence Content * * Searches Confluence content using CQL (Confluence Query Language). * Returns a formatted markdown response with search results. * * @param {SearchToolArgsType} args - Tool arguments for filtering search results * @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted search results * @throws Will return error message if search fails */ async function searchContent(args) { const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.search.tool.ts', 'searchContent'); methodLogger.debug('Tool called with args:', args); try { // Call the controller to search content const result = await atlassian_search_controller_js_1.default.search(args); methodLogger.debug('Successfully searched Confluence content'); // Convert the string content to an MCP text resource with the correct type const response = { content: [ { type: 'text', text: result.content, // Content now includes executed CQL and pagination information }, ], }; return response; } catch (error) { methodLogger.error('Error searching Confluence content:', error); // Format the error for MCP tools return (0, error_util_js_1.formatErrorForMcpTool)(error); } } /** * Register Atlassian Search MCP Tool * * Registers the search-content tool with the MCP server. * * @param {McpServer} server - The MCP server instance to register tools with */ function registerTools(server) { const toolLogger = logger_util_js_1.Logger.forContext('tools/atlassian.search.tool.ts', 'registerTools'); toolLogger.debug('Registering Atlassian Search tools...'); // Register the search content tool server.tool('conf_search', `Searches Confluence content. Supports multiple filter options: \`cql\` (for providing a complete custom Confluence Query Language string), \`title\` (text in title), \`spaceKey\`, \`labels\`, and \`contentType\` (page/blogpost). A general \`query\` parameter performs a basic text search (equivalent to CQL: text ~ "your query"). - IMPORTANT for \`cql\` users: Ensure your CQL syntax is correct, especially quoting terms in text searches (e.g., \`text ~ "search phrase"\`). Invalid CQL will result in an error. Refer to official Confluence CQL documentation. - Filters are generally combined with AND logic. - Supports pagination (\`limit\`, \`cursor\`). - The executed CQL and pagination information (including next cursor value) are included directly in the returned text content. - Returns Markdown formatted results with snippets and metadata. - Requires Confluence credentials.`, atlassian_search_types_js_1.SearchToolArgs.shape, searchContent); toolLogger.debug('Successfully registered Atlassian Search tools'); } exports.default = { registerTools };