@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
97 lines (96 loc) • 5.07 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_pages_controller_js_1 = __importDefault(require("../controllers/atlassian.pages.controller.js"));
const atlassian_pages_types_js_1 = require("./atlassian.pages.types.js");
/**
* MCP Tool: List Confluence Pages
*
* Lists Confluence pages with optional filtering by space, status, and limit.
* Returns a formatted markdown response with page details and pagination info.
*
* @param {ListPagesToolArgsType} args - Tool arguments for filtering pages
* @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted pages list
* @throws Will return error message if page listing fails
*/
async function listPages(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.pages.tool.ts', 'listPages');
methodLogger.debug('Tool called with args:', args);
try {
methodLogger.debug('Calling controller with options:', args);
// With updated controller signature, we can pass the tool args directly
const result = await atlassian_pages_controller_js_1.default.list(args);
methodLogger.debug('Successfully retrieved pages list');
return {
content: [
{
type: 'text',
text: result.content, // Content now includes pagination information
},
],
};
}
catch (error) {
methodLogger.error('Error listing pages:', error);
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* MCP Tool: Get Confluence Page Details
*
* Retrieves detailed information about a specific Confluence page.
* Returns a formatted markdown response with page content and metadata.
*
* @param {GetPageToolArgsType} args - Tool arguments containing the page ID
* @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} MCP response with formatted page details
* @throws Will return error message if page retrieval fails
*/
async function getPage(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.pages.tool.ts', 'getPage');
methodLogger.debug('Tool called with args:', args);
try {
// Call the controller to get page details - we can now pass args directly
const result = await atlassian_pages_controller_js_1.default.get(args);
methodLogger.debug('Successfully retrieved page details');
// Convert the string content to an MCP text resource with the correct type
return {
content: [
{
type: 'text',
text: result.content,
},
],
};
}
catch (error) {
methodLogger.error('Error retrieving page details:', error);
// Format the error for MCP tools
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* Register Atlassian Pages MCP Tools
*
* Registers the list-pages and get-page 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 toolLogger = logger_util_js_1.Logger.forContext('tools/atlassian.pages.tool.ts', 'registerTools');
toolLogger.debug('Registering Atlassian Pages tools...');
// Register the list pages tool
server.tool('conf_ls_pages', `Lists pages within specified spaces (by \`spaceId\` or \`spaceKey\`) or globally. Filters by \`title\` (NOTE: this is an EXACT match on the page title), \`status\` (current, archived, etc.). Supports sorting (\`sort\`) and pagination (\`limit\`, \`cursor\`).
- Returns a formatted list of pages including ID, title, status, space ID, author, version, and URL.
- Pagination information including next cursor value is included at the end of the returned text content.
- For partial title matching or full-text content search, use the \`conf_search\` tool.
- Requires Confluence credentials.`, atlassian_pages_types_js_1.ListPagesToolArgs.shape, listPages);
// Register the get page details tool
server.tool('conf_get_page', `Retrieves the full content (converted to Markdown) and metadata for a specific Confluence page using its numeric ID (\`pageId\`).\n- Includes complete page body, title, space info, author, version, labels, and URL.\nUse this after finding a page ID via \`confluence_list_pages\` or \`confluence_search\` to get its full content.\nReturns comprehensive page details formatted as Markdown.`, atlassian_pages_types_js_1.GetPageToolArgs.shape, getPage);
toolLogger.debug('Successfully registered Atlassian Pages tools');
}
exports.default = { registerTools };