Automate your Confluence workflow directly from Claude Code β publish pages, sync content, and upload images without leaving your terminal.
GitHub: https://github.com/tariqulislam/confluence-mcp-server
MCP stands for Model Context Protocol β an open standard that lets AI assistants like Claude Code connect to external tools and services. An MCP server acts as a bridge: it exposes a set of tools that Claude Code can call, allowing it to interact with third-party systems (like Confluence) on your behalf.
In this guide you will learn:
confluence-mcp-mock/
βββ .env β your credentials (never committed)
βββ .env.example β template
βββ .mcp.json β registers MCP servers with Claude Code
βββ confluence-mcp/
β βββ src/
β β βββ index.ts β entry point
β β βββ server.ts β tool registration
β β βββ config.ts β env validation (Zod)
β β βββ confluence/
β β β βββ client.ts β Axios HTTP client
β β β βββ api.ts β REST API calls
β β β βββ parser.ts β XHTML to structured data
β β β βββ markdown-converter.ts
β β βββ tools/ β one file per MCP tool
β β βββ connection-check.ts
β β βββ list-pages.ts
β β βββ publish-page.ts
β β βββ read-save-page.ts
β β βββ upload-images.ts
β β βββ sync-pages.ts
β βββ build/ β compiled output
βββ .claude/skills/ β slash command definitions
βββ confluence-conn-check/
βββ confluence-page-list/
βββ publish-to-confluence/
βββ confluence-upload-images/
βββ confluence-sync-pages/
The server reads all credentials from a single .env
file at the project root. Copy the example template:
cp .env.example .env
Then fill in the four Confluence variables:
CONFLUENCE_URL=https://your-confluence-instance.com/confluence/
CONFLUENCE_USER=your.email@company.com
CONFLUENCE_PERSONAL_ACCESS_TOKEN=your_token_here
CONFLUENCE_SPACE_KEY=MYSPACE
The four variables you need:
CONFLUENCE_URL β Base URL of your Confluence instance. Must end with a trailing slash.
Example: https://confluence.company.com/confluence/
CONFLUENCE_USER β The email address tied to your Confluence account.
CONFLUENCE_PERSONAL_ACCESS_TOKEN β A Bearer token generated in Confluence settings.
CONFLUENCE_SPACE_KEY β The space key where new pages will be created. Example: ENGINEERING
When the server starts, config.ts
reads the .env
file and validates every variable using Zod β a TypeScript schema library. If any variable is missing or malformed, the server exits with a clear error instead of failing silently later.
// confluence-mcp/src/config.ts (simplified)
import dotenv from 'dotenv';
import { z } from 'zod';
dotenv.config({ path: join(__dirname, '..', '..', '.env') });
const envSchema = z.object({
CONFLUENCE_URL: z.string().url(),
CONFLUENCE_USER: z.string().email(),
CONFLUENCE_PERSONAL_ACCESS_TOKEN: z.string().min(1),
CONFLUENCE_SPACE_KEY: z.string().min(1),
});
export const config = envSchema.parse(process.env);
The validated config is imported by client.ts
, which creates a single Axios instance used by every tool:
// confluence-mcp/src/confluence/client.ts (simplified)
const client = axios.create({
baseURL: config.CONFLUENCE_URL,
headers: {
Authorization: `Bearer ${config.CONFLUENCE_PERSONAL_ACCESS_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
timeout: 30000,
});
Credentials are set once here and never repeated anywhere else in the codebase.
Claude Code discovers MCP servers through the .mcp.json
file in the project root:
{
"mcpServers": {
"confluence": {
"command": "node",
"args": ["./confluence-mcp/build/index.js"]
}
}
}
This tells Claude Code: "When this project is open, launch the node process at that path and communicate with it over stdio."
cd confluence-mcp && npm install
npm run build
During development, use watch mode so the server recompiles on every save:
npm run watch
The server follows a clean three-layer pattern:
Claude Code
β (MCP protocol over stdio)
βΌ
server.ts β registers tools, routes calls
β
βΌ
tools/*.ts β one file per tool, handles input/output
β
βΌ
confluence/api.ts β REST API calls (Confluence v1 endpoints)
server.ts
declares every tool's name, description, and input schema in the ListToolsRequestSchema
handler. Claude Code reads this to understand what tools exist. Calls are then routed in the CallToolRequestSchema
handler:
// server.ts (simplified)
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'confluence_connection_check',
description: 'Verify connection to Confluence and check authentication.',
inputSchema: { type: 'object', properties: {}, required: [] },
},
{
name: 'confluence_list_pages',
description: 'List all child pages under a parent page.',
inputSchema: {
type: 'object',
properties: {
parent_page_id: { type: 'string', description: 'ID of the parent page' },
},
required: ['parent_page_id'],
},
},
],
}));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
switch (request.params.name) {
case 'confluence_connection_check':
return { content: [{ type: 'text', text: await handleConnectionCheck() }] };
case 'confluence_list_pages':
return { content: [{ type: 'text', text: await handleListPages(args) }] };
}
});
confluence_connection_check β Verifies auth and returns server/user info
confluence_list_pages β Lists all child pages under a parent
confluence_read_save_page β Downloads a page (sections, tables, images, comments) to local JSON
confluence_publish_page β Converts markdown to Confluence XHTML and creates/updates a page
confluence_upload_images β Bulk-uploads images from a local directory as page attachments
confluence_sync_pages β Syncs all child pages to local markdown with change tracking
Skills are the user-friendly layer on top of raw MCP tools. A skill is a directory under .claude/skills/
containing a SKILL.md
file.
.claude/skills/confluence-conn-check/
βββ SKILL.md
---
name: confluence-conn-check
description: Verify Confluence server connection and authentication.
argument-hint: (no arguments required)
---
Test the connection to Confluence and verify your credentials.
## Usage
/confluence-conn-check
## MCP Tool
confluence_connection_check
The three frontmatter fields that matter:
name β becomes the slash command (e.g. /confluence-conn-check
)
description β shown in the /
autocomplete menu and used for auto-discovery by Claude
argument-hint β hint shown in autocomplete, e.g. <parent_page_id>
or (no arguments required)
When you type /confluence-conn-check
in Claude Code, it reads SKILL.md
, knows which MCP tool to call, and formats the response back to you.
Verify your credentials before doing anything else.
/confluence-conn-check
Expected response:
{
"status": "success",
"user": {
"displayName": "Jane Doe",
"email": "jane.doe@company.com"
},
"server": {
"version": "8.5.0",
"baseUrl": "https://confluence.company.com/confluence"
}
}
List all child pages under a parent so you can find page IDs.
/confluence-page-list 123456789
Response:
{
"status": "success",
"message": "Found 3 child page(s)",
"pages": [
{ "id": "987654321", "title": "Getting Started" },
{ "id": "987654322", "title": "API Reference" }
]
}
Download a full page β sections, tables, images, and comments β and save it locally as structured JSON.
/confluence-page-read-save-content 987654321
Saves to:
confluence-docs/con_<parentId>_<pageId>/
βββ sections_and_sub_sections_contents.json
βββ comments_contents.json
βββ images/
βββ screenshot.png
βββ diagram.jpg
Convert a markdown file to Confluence storage format and publish it. Images referenced in the markdown are automatically uploaded as attachments.
Create a new page:
/publish-to-confluence 123456789 docs/architecture.md
Update an existing page:
/publish-to-confluence 123456789 docs/architecture.md 987654321
The markdown converter handles headings, bold/italic, fenced code blocks with syntax highlighting, ordered and unordered lists (nested), pipe tables, local and external images, blockquotes, and horizontal rules.
Bulk-upload images from a local directory with configurable rate-limit control.
/confluence-upload-images 987654321 ./screenshots
/confluence-upload-images 987654321 ./screenshots 1 3000
Rate-limit tuning guide:
batch_size=1, delay_ms=3000
β safest, use on aggressive instancesbatch_size=3, delay_ms=2000
β default, works for most instancesbatch_size=5, delay_ms=1000
β faster, for lightly loaded on-premise serversDownload all child pages under a parent as local markdown files. On repeat runs, only pages that actually changed (version bump or new attachment) are re-downloaded.
/confluence-sync-pages 6656101928
Output structure:
confluence_doc_md/
βββ parent_6656101928/
βββ manifest.json β change-tracking index
βββ page_987654321/
β βββ page.md
β βββ comments.json
β βββ images/
βββ page_987654322/
βββ page.md
Each page.md
starts with a metadata header:
> Page ID: 987654321
> Version: 5
> Last modified: 2026-05-20T10:30:00.000Z
[page body]
---
## Comments
### Comment by jane.doe (2026-05-19T09:00:00.000Z)
Comment text here.
Change detection logic:
/confluence-conn-check
/confluence-page-list 100000001
/publish-to-confluence 100000002 docs/my-feature.md
/publish-to-confluence 100000002 docs/my-feature.md 987654321
/confluence-sync-pages 100000001
To extend the server with a custom tool, follow four steps.
1. Create the tool file at confluence-mcp/src/tools/your-tool.ts
:
import { z } from 'zod';
export const yourToolSchema = z.object({
page_id: z.string().describe('The Confluence page ID'),
});
export async function handleYourTool(input: z.infer<typeof yourToolSchema>) {
return JSON.stringify({ status: 'success', data: {} }, null, 2);
}
2. Register in server.ts β add to the tool list and the switch statement:
import { handleYourTool } from './tools/your-tool.js';
// in ListToolsRequestSchema handler:
{ name: 'confluence_your_tool', description: '...', inputSchema: { ... } }
// in CallToolRequestSchema handler:
case 'confluence_your_tool':
return { content: [{ type: 'text', text: await handleYourTool(args) }] };
3. Create the skill at .claude/skills/your-tool/SKILL.md
following the format in Step 6.
4. Rebuild and restart:
cd confluence-mcp && npm run build
**MCP server not **
Run npm run build
inside confluence-mcp/
and check for TypeScript errors. Verify .mcp.json
points to ./confluence-mcp/build/index.js
. Fully restart Claude Code β the server process is launched at startup.
401 Authentication Error
Regenerate your Personal Access Token in Confluence settings. Confirm CONFLUENCE_USER
is the email associated with the token.
URL errors
CONFLUENCE_URL
must end with a trailing slash. If behind a VPN, connect before running.
Publishing formatting issues
Tables need a header separator row (|---|---|
). Avoid emoji and raw angle bracket characters (<
, >
) directly inside table cells β Confluence's XHTML parser rejects them.
Rate limit exceeded during image upload
Slow down: /confluence-upload-images <page_id> <dir> 1 4000
The full stack in one view:
.env
β credentials, never committedconfig.ts
β Zod validates env at startupclient.ts
β single Axios instance with Bearer authapi.ts
β Confluence REST v1 endpoint callstools/*.ts
β one handler per MCP toolserver.ts
β declares tools to Claude Code via MCP protocol.mcp.json
β tells Claude Code where to find the server.claude/skills/*/SKILL.md
β slash commands that wrap MCP toolsWith this architecture you can publish markdown documentation, sync entire Confluence spaces, and upload images β all from a single Claude Code session.
Source code: github.com/tariqulislam/confluence-mcp-server