mcp-confluence-fy
v1.0.4
Published
Confluence API client and MCP server for Confluence integration
Maintainers
Readme
Confluence MCP Server and API Client
This package provides a Model Context Protocol (MCP) server for Confluence Wiki and a standalone Confluence API client. It allows you to:
- Use it as a JavaScript/Node.js library to interact with Confluence
- Run it as an MCP server for Cursor IDE
Features
- Search Confluence Wiki pages
- Read page content and details
- Create new wiki pages
- Update existing wiki pages
- Insert Confluence modules (macros)
- List available spaces
- Manage page comments, attachments, and labels
- Handle page hierarchy and organization
- Create and manage content templates
- Export pages to different formats
- View page permissions and restrictions
- Seamless integration with Cursor IDE
Prerequisites
- Node.js 16 or higher
- Confluence API token
- Cursor IDE
Installation
As a dependency in your project
npm install mcp-confluence-fyAs a global CLI tool
npm install -g mcp-confluence-fyNo installation necessary (using npx)
npx mcp-confluence-fyUsage
As a JavaScript Library
You can use this package as a regular JavaScript library to interact with Confluence:
import { createConfluenceClient } from 'mcp-confluence-fy';
// Create a Confluence client
const confluence = createConfluenceClient({
host: 'https://your-confluence-instance.atlassian.net',
username: 'your_username',
password: 'your_api_token'
});
// Use the client to interact with Confluence
async function example() {
// List spaces
const spaces = await confluence.listSpaces(10);
// Search for pages
const searchResults = await confluence.searchWiki('your search query');
// Get page information
const pageInfo = await confluence.getPageInfo('123456');
// Get page content
const content = await confluence.getPageContent('123456', 'markdown');
// Create a new page
const newPage = await confluence.createPage({
title: 'New Page Title',
content: '# New Page\n\nThis is a new page created via the API.',
spaceKey: 'SPACE',
isMarkdown: true
});
// Update an existing page
const updatedPage = await confluence.updatePage({
pageId: '123456',
title: 'Updated Title',
content: '# Updated Page\n\nThis page has been updated.',
isMarkdown: true
});
// Insert a Confluence macro/module
const pageWithMacro = await confluence.insertModule({
pageId: '123456',
moduleName: 'info',
moduleParams: {
title: 'Information Macro',
icon: 'true'
},
position: 'end' // 'start', 'end', or element ID
});
// Get page attachments
const attachments = await confluence.getAttachments('123456');
// Get page comments
const comments = await confluence.getComments('123456');
// Add a new comment to a page
const comment = await confluence.addComment('123456', 'This is a new comment', true);
// Work with labels
const labels = await confluence.getPageLabels('123456');
await confluence.addLabels('123456', ['important', 'documentation']);
await confluence.removeLabel('123456', 'outdated');
// Work with page hierarchy
const pageTree = await confluence.getPageTree('123456', 3); // Get 3 levels of children
await confluence.movePageToParent('123456', '789012'); // Move page to a new parent
// Work with templates
const template = await confluence.createTemplate(
'SPACE',
'Meeting Notes',
'# Meeting Notes\n\n**Date:** \n**Participants:** \n\n## Agenda\n\n## Action Items',
'Template for team meeting notes'
);
const spaceTemplates = await confluence.getSpaceTemplates('SPACE');
// Export pages
const pdfExport = await confluence.exportPageToPDF('123456');
// Get space statistics
const stats = await confluence.getSpaceContentStats('SPACE');
// Get page permissions
const restrictions = await confluence.getPageRestrictions('123456');
// Get user information
const userInfo = await confluence.getUserInfo('username');
}As an MCP Server in your code
You can also create and start the MCP server programmatically:
import { createConfluenceServer } from 'mcp-confluence-fy';
// Create the server
const server = createConfluenceServer({
host: 'https://your-confluence-instance.atlassian.net',
username: 'your_username',
password: 'your_api_token',
port: 9001,
useStdio: false // set to true for use with Cursor IDE
});
// Start the server
server.start()
.then(() => {
console.log('Server started successfully');
})
.catch(err => {
console.error('Failed to start server:', err);
});As a CLI Tool
If installed globally, you can run the MCP server directly from the command line:
# Set environment variables
export CONFLUENCE_HOST="https://your-confluence-instance.atlassian.net"
export CONFLUENCE_USERNAME="your_username"
export CONFLUENCE_PASSWORD="your_api_token"
# Start the server with HTTP/SSE transport
mcp-confluence-fy
# Start the server with stdio transport (for Cursor IDE)
mcp-confluence-fy --stdioAlternatively, you can create a .env file with these variables:
CONFLUENCE_HOST=https://your-confluence-instance.atlassian.net
CONFLUENCE_USERNAME=your_username
CONFLUENCE_PASSWORD=your_api_token
PORT=9001Configuring with Cursor IDE
To use this MCP with Cursor, you have two options:
Option 1: Using npx (recommended)
Add the following to your Cursor configuration:
{
"mcpServers": {
"confluence": {
"command": "npx",
"args": [
"-y",
"mcp-confluence-fy",
"--stdio"
],
"env": {
"CONFLUENCE_HOST": "https://your-confluence-instance.atlassian.net",
"CONFLUENCE_USERNAME": "your_username",
"CONFLUENCE_PASSWORD": "your_api_token"
}
}
}
}This will automatically download and run the latest version of mcp-confluence-fy without requiring installation.
Option 2: Using an installed version
- Install the package globally:
npm install -g mcp-confluence-fy - Add the following to your Cursor configuration:
{
"mcpServers": {
"confluence": {
"command": "mcp-confluence-fy",
"args": ["--stdio"],
"env": {
"CONFLUENCE_HOST": "https://your-confluence-instance.atlassian.net",
"CONFLUENCE_USERNAME": "your_username",
"CONFLUENCE_PASSWORD": "your_api_token"
}
}
}
}Available Methods
The Confluence client provides these methods:
getPageContent(pageId, format)- Get content from a specific pagesearchWiki(query, limit)- Search for Confluence pagesgetPageInfo(pageId)- Get detailed information about a pagecreatePage({ title, content, spaceKey, parentId, isMarkdown })- Create a new pageupdatePage({ pageId, title, content, isMarkdown })- Update an existing pagelistSpaces(limit, type)- List available Confluence spacesinsertModule({ pageId, moduleName, moduleParams, position })- Insert a Confluence macrogetAttachments(pageId, limit)- Get attachments from a pagegetComments(pageId, limit)- Get comments from a pageaddComment(pageId, content, isMarkdown)- Add a comment to a pagegetPageLabels(pageId)- Get labels from a pageaddLabels(pageId, labels)- Add labels to a pageremoveLabel(pageId, labelName)- Remove a label from a pagegetPageTree(rootPageId, depth)- Get page hierarchy treemovePageToParent(pageId, newParentId)- Move a page to a new parentcreateTemplate(spaceKey, name, content, description, isMarkdown)- Create a content templategetSpaceTemplates(spaceKey, limit)- Get templates from a spaceexportPageToPDF(pageId, expand)- Generate PDF export URLgetSpaceContentStats(spaceKey)- Get content statistics for a spacegetPageRestrictions(pageId)- Get page permissionsgetUserInfo(username)- Get information about a user
Available MCP Tools for Cursor IDE
The MCP server provides these specialized tools optimized for Cursor IDE:
mcp_confluence_search_wiki- Search for recent pages in Confluence Wikimcp_confluence_get_wiki_content- Get content from a Confluence Wiki pagemcp_confluence_create_page- Create a new page with built-in space selectionmcp_confluence_update_page- Update an existing page with helpful guidancemcp_confluence_get_page_info- Get detailed information about a pagemcp_confluence_list_spaces- List all available spaces in Confluencemcp_confluence_get_space- Get detailed information about a specific spacemcp_confluence_get_space_content- Get list of content from a specific spacemcp_confluence_get_attachments- Get formatted list of page attachmentsmcp_confluence_get_comments- Get formatted list of page commentsmcp_confluence_add_comment- Add a comment to a pagemcp_confluence_get_page_tree- Get nicely formatted page hierarchymcp_confluence_get_page_labels- Get labels from a pagemcp_confluence_add_labels- Add labels to a pagemcp_confluence_remove_label- Remove a label from a pagemcp_confluence_move_page- Move a page to a new parentmcp_confluence_create_template- Create a content templatemcp_confluence_get_space_templates- Get templates from a spacemcp_confluence_export_page_to_pdf- Generate PDF export URLmcp_confluence_get_page_restrictions- Get page permissionsmcp_confluence_get_user_info- Get information about a usermcp_confluence_insert_module- Insert a Confluence module/macro into a page
Development
To run the server in development mode with auto-reload:
git clone https://github.com/fuyoukache/mcp-confluence-fy.git
cd mcp-confluence-fy
npm install
npm run devLicense
ISC
Credits
Built using the Model Context Protocol and Confluence.js API client.
