@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
64 lines (63 loc) • 3.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vendor_atlassian_search_service_js_1 = __importDefault(require("../services/vendor.atlassian.search.service.js"));
const logger_util_js_1 = require("../utils/logger.util.js");
const error_handler_util_js_1 = require("../utils/error-handler.util.js");
const pagination_util_js_1 = require("../utils/pagination.util.js");
const atlassian_search_formatter_js_1 = require("./atlassian.search.formatter.js");
const defaults_util_js_1 = require("../utils/defaults.util.js");
/**
* Controller for searching Confluence content.
* Provides functionality for searching content using CQL.
*/
/**
* Search Confluence content using CQL
* @param options - Search options including CQL query, cursor, and limit
* @returns Promise with formatted search results and pagination information
*/
async function search(options) {
const controllerLogger = logger_util_js_1.Logger.forContext('controllers/atlassian.search.controller.ts', 'search');
try {
controllerLogger.debug('Searching content with options:', options);
// Apply defaults and set a default query if none provided
const mergedOptions = (0, defaults_util_js_1.applyDefaults)(options, {
limit: defaults_util_js_1.DEFAULT_PAGE_SIZE,
cql: 'type IN (page, blogpost) ORDER BY lastmodified DESC',
});
// Process CQL query: escape special characters, add any filters
const processedCql = (0, atlassian_search_formatter_js_1.processCqlQuery)(mergedOptions.cql);
controllerLogger.debug('Processed CQL query:', { cql: processedCql });
// Prepare search parameters for the service
const searchParams = {
cql: processedCql,
limit: mergedOptions.limit,
cursor: mergedOptions.cursor,
excerpt: 'highlight', // Show content matching search terms
};
// Call the service to perform the search
const searchResponse = await vendor_atlassian_search_service_js_1.default.search(searchParams);
controllerLogger.debug('Search returned results:', {
count: searchResponse.results.length,
hasMoreResults: !!searchResponse._links?.next,
});
// Extract pagination information for the response
const pagination = (0, pagination_util_js_1.extractPaginationInfo)(searchResponse, pagination_util_js_1.PaginationType.CURSOR);
// Format the results for display
const formattedContent = (0, atlassian_search_formatter_js_1.formatSearchResults)(searchResponse.results);
return {
content: formattedContent,
pagination,
};
}
catch (error) {
return (0, error_handler_util_js_1.handleControllerError)(error, {
entityType: 'content',
operation: 'search',
source: 'atlassian.search.controller.ts',
});
}
}
exports.default = { search };