Confluence附件管理服务器

一个用于从Confluence页面下载和读取附件的模型上下文协议(MCP)服务器,支持批量下载、文件内容读取和管理。

  • by choipureum
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 choipureum/confluence-attachment-mcp-server

使用说明

汇流附件MCP服务器

模型上下文协议(MCP)服务器,使AI助手能够从Confluence页面下载和读取附件。

特性

  • 🔍 页面搜索:按标题搜索Confluence页面
  • 📄 页面信息:获取页面详细信息和附件计数
  • 📎 附件管理:列出并下载附件
  • ⬇️ 批量下载:从页面下载所有附件
  • 📖 内容读取:读取和分析下载的文件
  • 📁 文件管理:列出并管理下载的文件
  • 🐳 Docker优化:使用Alpine Linux进行多阶段构建
  • 🔧 模块化架构:干净、可维护的代码结构
  • 🛡️ 安全:非root用户执行
  • 📊 健康检查:内置容器健康监测

快速开始

先决条件

  • Python 3.11+
  • Docker(推荐)
  • 汇流API访问

Docker镜像

  • 图像名称: confluence-attachment-mcp:latest
  • 尺寸:~183MB(优化的Alpine Linux)
  • 基础:Python 3.11-alpine
  • 建筑:多阶段构建以实现优化

环境设置

创建一个 .env 文件:

CONFLUENCE_URL=https://your-domain.atlassian.net
CONFLUENCE_USERNAME=your-email@example.com
CONFLUENCE_API_TOKEN=your-api-token
CONFLUENCE_SPACE_KEY=YOUR_SPACE_KEY
MCP_SERVER_NAME=confluence-attachments
MCP_SERVER_VERSION=1.0.0

Docker(推荐)

# Build and run
./scripts/run.sh

# Or manually
docker build -f config/Dockerfile -t confluence-attachment-mcp:latest .
docker run -d --name confluence-mcp \
  -e CONFLUENCE_URL="https://your-domain.atlassian.net/wiki" \
  -e CONFLUENCE_USERNAME="your-email@example.com" \
  -e CONFLUENCE_API_TOKEN="your-api-token" \
  -e CONFLUENCE_SPACE_KEY="YOUR_SPACE_KEY" \
  -v $(pwd)/downloads:/app/downloads \
  confluence-attachment-mcp:latest

地方发展

# Install dependencies
pip install -r requirements.txt

# Run server
python main.py

MCP配置

光标集成

添加到光标MCP配置中:

{
  "mcpServers": {
    "confluence-attachments": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--name",
        "confluence-attachments-mcp",
        "-e",
        "CONFLUENCE_URL",
        "-e",
        "CONFLUENCE_USERNAME",
        "-e",
        "CONFLUENCE_API_TOKEN",
        "-e",
        "CONFLUENCE_SPACE_KEY",
        "-v",
        "${workspaceFolder}/downloads:/app/downloads",
        "confluence-attachment-mcp:latest"
      ],
      "env": {
        "MCP_VERBOSE": "true",
        "CONFLUENCE_URL": "https://your-domain.atlassian.net/wiki",
        "CONFLUENCE_USERNAME": "your-email@example.com",
        "CONFLUENCE_API_TOKEN": "your-api-token-here",
        "CONFLUENCE_SPACE_KEY": "YOUR_SPACE_KEY"
      }
    }
  }
}

可用工具

工具 说明 参数
confluence_search_pages_by_title 按标题搜索页面 title, space_key
confluence_get_page_info 获取页面详细信息 page_id
confluence_get_page_attachments 列出页面附件 page_id
confluence_download_attachment 下载单个附件 page_id, attachment_title, filename
confluence_download_all_attachments 下载所有附件 page_id
confluence_read_attachment_content 读取文件内容 filename
confluence_list_downloaded_files 列出下载的文件 无

使用示例

搜索项目文档

confluence_search_pages_by_title("Project Plan", "DEV")

下载特定附件

confluence_download_attachment("12345", "pdf-test.pdf")

下载所有附件

confluence_download_all_attachments("12345")

读取文件内容

confluence_read_attachment_content("project_plan.pdf")

项目结构

confluence-attachment-mcp/
├── src/
│   ├── mcp_server/          # MCP server implementation
│   ├── confluence/          # Confluence integration
│   └── utils/               # Utility classes
├── config/                  # Configuration files
├── scripts/                 # Build and deployment scripts
├── docs/                    # Documentation
├── examples/                # Usage examples
├── main.py                  # Entry point
├── requirements.txt         # Python dependencies
├── pyproject.toml          # Project configuration
└── README.md               # This file

发展

设置开发环境

# Install development dependencies
pip install -r requirements.txt
pip install -e .

# Run tests
pytest

# Code formatting
black src/
flake8 src/
mypy src/

构建Docker镜像

# Build image
docker build -f config/Dockerfile -t confluence-attachment-mcp:latest .

# Run container
docker run -it --rm confluence-attachment-mcp:latest

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 如果适用,添加测试
  5. 提交拉取请求

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

支持

  • 为bug或功能请求创建问题
  • 查看文档 docs/ 文件夹
  • 审查现有问题以寻求解决方案

更新日志

v1.0.0

  • 初始版本
  • MCP服务器的基本功能
  • 汇流附件管理
  • Docker支持
  • 模块化代码架构
  • 多阶段Docker优化
  • 安全改进(非root用户)
  • 健康检查实施
  • 增强的错误处理
  • 文件类型检测和内容读取