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

113 lines (112 loc) 4.45 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleGet = handleGet; exports.handlePost = handlePost; exports.handlePut = handlePut; exports.handlePatch = handlePatch; exports.handleDelete = handleDelete; const vendor_atlassian_api_service_js_1 = __importDefault(require("../services/vendor.atlassian.api.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 jq_util_js_1 = require("../utils/jq.util.js"); /** * @namespace AtlassianApiController * @description Controller for handling generic Confluence API requests. * Orchestrates calls to the Atlassian API service and handles * response formatting (JQ filtering, TOON/JSON output). * * Architecture: * - Tool → Controller (this file) → Service → Transport * - Controller handles: JQ filtering, output formatting, error context * - Service handles: Credentials, path normalization, API calls */ // Logger instance for this module const logger = logger_util_js_1.Logger.forContext('controllers/atlassian.api.controller.ts'); /** * Shared handler for all HTTP methods * * @param method - HTTP method (GET, POST, PUT, PATCH, DELETE) * @param options - Request options including path, queryParams, body (for non-GET), and jq filter * @returns Promise with formatted response content */ async function handleRequest(method, options) { const methodLogger = logger.forMethod(`handle${method}`); try { methodLogger.debug(`Making ${method} request`, { path: options.path, ...(options.body && { bodyKeys: Object.keys(options.body) }), }); // Call the service layer (returns TransportResponse with data and rawResponsePath) const response = await vendor_atlassian_api_service_js_1.default.request(options.path, { method, queryParams: options.queryParams, body: options.body, }); methodLogger.debug('Successfully received response from service'); // Apply JQ filter if provided, otherwise return raw data const result = (0, jq_util_js_1.applyJqFilter)(response.data, options.jq); // Convert to output format (TOON by default, JSON if requested) const useToon = options.outputFormat !== 'json'; const content = await (0, jq_util_js_1.toOutputString)(result, useToon); return { content, rawResponsePath: response.rawResponsePath, }; } catch (error) { throw (0, error_handler_util_js_1.handleControllerError)(error, { entityType: 'API', operation: `${method} request`, source: `controllers/atlassian.api.controller.ts@handle${method}`, additionalInfo: { path: options.path }, }); } } /** * Generic GET request to Confluence API * * @param options - Options containing path, queryParams, and optional jq filter * @returns Promise with raw JSON response (optionally filtered) */ async function handleGet(options) { return handleRequest('GET', options); } /** * Generic POST request to Confluence API * * @param options - Options containing path, body, queryParams, and optional jq filter * @returns Promise with raw JSON response (optionally filtered) */ async function handlePost(options) { return handleRequest('POST', options); } /** * Generic PUT request to Confluence API * * @param options - Options containing path, body, queryParams, and optional jq filter * @returns Promise with raw JSON response (optionally filtered) */ async function handlePut(options) { return handleRequest('PUT', options); } /** * Generic PATCH request to Confluence API * * @param options - Options containing path, body, queryParams, and optional jq filter * @returns Promise with raw JSON response (optionally filtered) */ async function handlePatch(options) { return handleRequest('PATCH', options); } /** * Generic DELETE request to Confluence API * * @param options - Options containing path, queryParams, and optional jq filter * @returns Promise with raw JSON response (optionally filtered) */ async function handleDelete(options) { return handleRequest('DELETE', options); }