Confluence MCP Server
# Confluence MCP Server
读取和分析 Confluence 文档内容的 MCP Server。支持文字、表格、代码块、图片等内容的提取和转换。
## 功能
- **get_confluence_page** — 获取页面完整内容(Markdown 格式),用于问答和分析
- **get_page_structure** — 获取页面结构概览(目录、是否有表格/代码/图片)
- **get_child_pages** — 获取子页面列表
- **get_page_attachments** — 获取附件列表
## 安装
### 1. 创建虚拟环境并安装
```bash
cd confluence-mcp
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate
pip install -e .
```
### 2. 配置环境变量
复制 `.env.example` 为 `.env` 并编辑:
```bash
cp .env.example .env
```
```ini
# Confluence Server 地址(不要尾部斜杠)
CONFLUENCE_BASE_URL=https://confluence.yourcompany.com
# Personal Access Token
# 获取方式: Confluence → 右上角头像 → 设置 → Personal Access Tokens → 创建
CONFLUENCE_PAT=your_token_here
# 内网自签证书时设为 false
CONFLUENCE_VERIFY_SSL=true
```
### 3. 测试运行
```bash
# 直接运行看是否正常启动
python -m confluence_mcp.server
# 或使用 mcp dev 工具调试
mcp dev confluence_mcp/server.py
```
## 集成到 VS Code / Copilot Chat
在 VS Code 的 `settings.json` 中添加:
```json
{
"mcp": {
"servers": {
"confluence": {
"command": "python",
"args": ["-m", "confluence_mcp.server"],
"cwd": "C:\\Users\\wang2\\mcp\\confluence-mcp",
"env": {
"CONFLUENCE_BASE_URL": "https://confluence.yourcompany.com",
"CONFLUENCE_PAT": "your_token_here",
"CONFLUENCE_VERIFY_SSL": "true"
}
}
}
}
}
```
> 也可以不在 settings.json 里写 env,而是让 server 从 `.env` 文件读取。
## 集成到 Claude Desktop
在 `claude_desktop_config.json` 中添加:
```json
{
"mcpServers": {
"confluence": {
"command": "C:\\Users\\wang2\\mcp\\confluence-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "confluence_mcp.server"],
"cwd": "C:\\Users\\wang2\\mcp\\confluence-mcp",
"env": {
"CONFLUENCE_BASE_URL": "https://confluence.yourcompany.com",
"CONFLUENCE_PAT": "your_token_here"
}
}
}
}
```
## 使用方式
配置完成后,在 Copilot Chat 或 Claude 对话中直接发送:
```
帮我看一下这个文档的内容:https://confluence.yourcompany.com/display/TEAM/Some+Page
这个文档里关于部署流程是怎么写的?
总结一下这个页面:https://confluence.yourcompany.com/pages/viewpage.action?pageId=12345
```
LLM 会自动调用 `get_confluence_page` 获取内容,然后基于内容回答你的问题。
## 关于内网请求拦截
本工具在 HTTP 请求中使用了浏览器 User-Agent 和完整的浏览器请求头,以规避可能的非浏览器请求拦截。如果仍然被拦截,可能需要:
1. 将请求源 IP 加入白名单
2. 或者联系 IT 确认 REST API 是否需要额外配置
## 支持的 URL 格式
- `https://confluence.example.com/pages/viewpage.action?pageId=12345`
- `https://confluence.example.com/display/SPACE/Page+Title`
- `https://confluence.example.com/spaces/SPACE/pages/12345/Page+Title`
- `https://confluence.example.com/wiki/spaces/SPACE/pages/12345/...`
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose with no overlap. get_child_pages lists child pages, get_confluence_page fetches full content, get_page_attachments lists attachments, get_page_images downloads images, get_page_structure provides an overview, and search_in_page searches within a page. The descriptions make it easy to differentiate them.
All tool names follow a consistent verb_noun pattern (e.g., get_child_pages, get_confluence_page, get_page_attachments). The naming is uniform across all six tools, using snake_case and starting with a verb that describes the action.
With 6 tools, the server is well-scoped for its purpose of interacting with Confluence pages. Each tool serves a specific function in browsing, retrieving, and analyzing page content, making the count appropriate without being too sparse or overwhelming.
The toolset provides comprehensive coverage for reading and analyzing Confluence pages, including structure, content, attachments, images, and search. A minor gap is the lack of write operations (e.g., create or update pages), but for a read-focused server, the surface is nearly complete.