quintindk/mcp-confluence-attachments
If you are the rightful owner of mcp-confluence-attachments and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server and CLI tool for downloading images and draw.io diagrams from Confluence pages.
MCP Confluence Attachments
A Model Context Protocol (MCP) server and CLI tool for downloading images and draw.io diagrams from Confluence pages.
Features
- MCP Server: Expose Confluence attachment operations as MCP tools for AI assistants
- CLI Tool: Standalone command-line interface for downloading attachments
- Docker Support: Run as a containerized application
- Flexible Transport: Support for stdio and HTTP/SSE communication modes
- Smart Filtering: Download only images, only diagrams, or both
- Organized Storage: Automatic directory organization (images in root, diagrams in subdirectory)
Installation
Local Installation
- Clone this repository:
git clone <repository-url>
cd mcp-confluence-attachments
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
cp .env.example .env
# Edit .env with your Confluence credentials
Docker Installation
Option 1: Pull from Docker Hub (Recommended)
Pull the pre-built image:
docker pull quintindk/mcp-confluence-attachments:latest
Option 2: Build Locally
Build the Docker image yourself:
docker build -t mcp-confluence-attachments .
Quick Start with Claude Code (Recommended)
If you're using Claude Code, you can add the MCP server with a single command:
claude mcp add confluence-attachments -s user -- sh -c "docker run -i --rm -e MCP_DEBUG=false -v \$(pwd):/output -e LOG_LEVEL=INFO -e MCP_TRANSPORT=stdio -e CONFLUENCE_URL=https://your-instance.atlassian.net -e CONFLUENCE_PERSONAL_TOKEN=\$CONFLUENCE_TOKEN mcp-confluence-attachments"
Important notes:
- Replace
https://your-instance.atlassian.netwith your Confluence URL - Set the
CONFLUENCE_TOKENenvironment variable in your shell before running this command:export CONFLUENCE_TOKEN="your_personal_access_token" - The
-v $(pwd):/outputvolume mount ensures downloaded files appear in your current working directory - The
-s userflag installs the server for your user account only
MCP Server Usage
The MCP server exposes four tools for working with Confluence attachments:
Available Tools
-
list_attachments: List all attachments on a Confluence page
- Input:
page_id - Output: List of attachment metadata (ID, title, media type, file size, etc.)
- Input:
-
get_attachment_metadata: Get detailed metadata for a specific attachment
- Input:
page_id,attachment_id - Output: Complete attachment metadata
- Input:
-
download_all_attachments: Download all (or filtered) attachments from a page
- Input:
page_id,output_dir,download_images(bool),download_diagrams(bool) - Output: Download results for each attachment
- Input:
-
download_specific_attachment: Download a single attachment by ID
- Input:
page_id,attachment_id,output_path - Output: Download status and file details
- Input:
Running the MCP Server
Stdio Mode (for Claude Desktop/CLI integration)
python confluence_mcp_server.py
Or with explicit environment variables:
CONFLUENCE_URL="https://your-instance.atlassian.net" \
CONFLUENCE_PERSONAL_TOKEN="your_token" \
python confluence_mcp_server.py
HTTP/SSE Mode (for web-based clients)
MCP_TRANSPORT=sse python confluence_mcp_server.py
The server will start at http://0.0.0.0:8080 with:
- SSE endpoint:
http://0.0.0.0:8080/sse - Tools listing:
http://0.0.0.0:8080/tools
Claude Desktop Configuration (Manual Method)
Note: If you're using Claude Code, use the claude mcp add command shown in the Quick Start section above instead of manually editing config files.
For Claude Desktop, add to your config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Using Docker (Recommended):
{
"mcpServers": {
"confluence-attachments": {
"command": "sh",
"args": [
"-c",
"cd \"$(pwd)\" && docker run -i --rm -v $(pwd):/output -e MCP_TRANSPORT=stdio -e CONFLUENCE_URL=https://your-instance.atlassian.net -e CONFLUENCE_PERSONAL_TOKEN=$CONFLUENCE_TOKEN mcp-confluence-attachments"
]
}
}
}
Set the CONFLUENCE_TOKEN environment variable in your shell:
export CONFLUENCE_TOKEN="your_personal_access_token"
Using Python Directly:
{
"mcpServers": {
"confluence-attachments": {
"command": "python",
"args": ["/absolute/path/to/confluence_mcp_server.py"],
"env": {
"CONFLUENCE_URL": "https://your-instance.atlassian.net",
"CONFLUENCE_PERSONAL_TOKEN": "your_personal_access_token"
}
}
}
}
Environment Variables
Required
CONFLUENCE_URL: Base URL of your Confluence instance (e.g.,https://your-instance.atlassian.net)CONFLUENCE_PERSONAL_TOKEN: Personal Access Token for authentication
Optional MCP Server Settings
MCP_TRANSPORT: Communication mode (stdio,sse, orhttp) - default:stdioMCP_HOST: Server host address - default:0.0.0.0MCP_PORT: Server port - default:8080MCP_DEBUG: Enable debug logging (true/false) - default:falseMCP_RELOAD: Enable auto-reload in development - default:falseLOG_LEVEL: Logging level (DEBUG,INFO,WARNING,ERROR,CRITICAL) - default:INFO
CLI Tool Usage
The standalone CLI tool can be used independently of the MCP server:
python download_attachments.py <page_id> [output_dir]
Examples
# Download all attachments to current directory
python download_attachments.py 1142972070
# Download to specific directory
python download_attachments.py 1142972070 ./my-downloads
# View help
python download_attachments.py --help
Environment Variables for CLI
Set these in your shell or .env file:
export CONFLUENCE_URL="https://your-instance.atlassian.net"
export CONFLUENCE_PERSONAL_TOKEN="your_token_here"
Docker Usage
The Docker container runs the MCP server by default, making it easy to deploy as a service.
Running the MCP Server (Stdio Mode with Volume Mount)
For stdio mode (used by Claude Code and Claude Desktop), you need to mount your current directory so downloaded files appear on the host:
docker run -i --rm \
-v $(pwd):/output \
-e MCP_TRANSPORT=stdio \
-e CONFLUENCE_URL="https://your-instance.atlassian.net" \
-e CONFLUENCE_PERSONAL_TOKEN="your-token-here" \
mcp-confluence-attachments
Why the volume mount?
- Without
-v $(pwd):/output, files are written inside the container and aren't accessible on your host - The mount makes the current directory available at
/outputin the container - Downloaded files will appear in your current directory on the host
- When using relative paths (e.g.,
./downloads), they will be resolved relative to/outputin the container
Running the MCP Server (HTTP/SSE Mode)
Start the MCP server in a container:
docker run --rm \
-p 8080:8080 \
-e CONFLUENCE_URL="https://your-instance.atlassian.net" \
-e CONFLUENCE_PERSONAL_TOKEN="your-token-here" \
mcp-confluence-attachments
The server will be accessible at:
- SSE endpoint:
http://localhost:8080/sse - Tools listing:
http://localhost:8080/tools
Run in Background
docker run -d \
--name confluence-mcp \
-p 8080:8080 \
-e CONFLUENCE_URL="https://your-instance.atlassian.net" \
-e CONFLUENCE_PERSONAL_TOKEN="your-token-here" \
mcp-confluence-attachments
View logs:
docker logs -f confluence-mcp
Stop the server:
docker stop confluence-mcp
Using the CLI Tool in Docker
You can also use the CLI tool by overriding the entrypoint:
docker run --rm \
-v $(pwd)/output:/output \
-e CONFLUENCE_URL="https://your-instance.atlassian.net" \
-e CONFLUENCE_PERSONAL_TOKEN="your-token-here" \
--entrypoint python \
mcp-confluence-attachments download_attachments.py 1142972070 /output
This will create:
- Images in
output/(e.g.,output/Site Design.png) - Draw.io diagrams in
output/diagrams/(e.g.,output/diagrams/Site Design.drawio)
Docker Environment Variables
All MCP server environment variables can be set when running the container:
docker run --rm \
-p 8080:8080 \
-e CONFLUENCE_URL="https://your-instance.atlassian.net" \
-e CONFLUENCE_PERSONAL_TOKEN="your-token" \
-e MCP_TRANSPORT="sse" \
-e MCP_PORT="8080" \
-e MCP_DEBUG="true" \
-e LOG_LEVEL="DEBUG" \
mcp-confluence-attachments
What It Downloads
The tool downloads:
- Images: PNG, JPG, GIF, etc. (saved to root output directory)
- Draw.io Diagrams:
.drawiofiles (saved todiagrams/subdirectory)
It automatically skips:
- Temporary/draft files (starting with
~) - Files with "draft" in their media type
- Other file types (Word docs, PDFs, etc.)
Getting a Confluence Personal Access Token
- Log in to your Confluence instance
- Click your profile picture → Settings
- Go to Security → Personal Access Tokens
- Click Create token
- Give it a name and set expiration
- Copy the token (you won't be able to see it again!)
Development
Running Tests
# TODO: Add test instructions once tests are implemented
Project Structure
mcp-confluence-attachments/
├── .github/
│ └── workflows/
│ └── docker-publish.yml # GitHub Actions CI/CD workflow
├── confluence_mcp_server.py # Main MCP server
├── confluence_client.py # Confluence API client wrapper
├── config.py # Configuration management
├── download_attachments.py # Standalone CLI tool
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── Dockerfile # Docker container definition
├── CICD_SETUP.md # CI/CD setup guide
└── README.md # This file
Troubleshooting
Configuration Errors
If you see CONFLUENCE_URL environment variable not set:
- Make sure your
.envfile exists and contains the required variables - Or export them in your shell before running the server
Authentication Errors
If you get 401 or 403 errors:
- Verify your Personal Access Token is correct and not expired
- Check that your token has permissions to access the Confluence page
- Ensure the CONFLUENCE_URL matches your instance URL exactly
Connection Errors
If the server can't connect to Confluence:
- Verify your CONFLUENCE_URL is correct (include https://)
- Check your network connection and firewall settings
- Try accessing the Confluence URL in a web browser
CI/CD and Publishing
This project includes automated Docker image builds and publishing to Docker Hub using GitHub Actions.
Automated Builds
Every push to the main branch automatically:
- Builds a multi-platform Docker image (amd64 and arm64)
- Pushes the image to Docker Hub with the
latesttag - Updates the Docker Hub repository description
Version tags (e.g., v1.0.0) automatically create versioned images:
yourusername/mcp-confluence-attachments:v1.0.0yourusername/mcp-confluence-attachments:v1.0yourusername/mcp-confluence-attachments:v1
Setting Up CI/CD for Your Fork
If you fork this repository and want to publish to your own Docker Hub account:
- Read the detailed setup guide:
- Create a Docker Hub access token
- Add
DOCKERHUB_USERNAMEandDOCKERHUB_TOKENsecrets to your GitHub repository - Push to
mainor create a version tag
The workflow file is located at .github/workflows/docker-publish.yml.
License
[Add your license here]
Contributing
Contributions are welcome! Please open an issue or submit a pull request.