基于模型上下文协议(MCP)的Confluence集成服务器,允许AI助手通过标准化接口查询和管理Confluence页面内容。
# 克隆或下载项目
cd confluence-mcp-server
# 安装依赖
npm install
# 编译 TypeScript
npm run build
创建.env文件或设置以下环境变量:
# Confluence实例URL
CONFLUENCE_URL=https://your-domain.atlassian.net/wiki
# 认证方式 1: 个人访问令牌(推荐)
CONFLUENCE_PERSONAL_TOKEN=your_personal_token_here
# 认证方式 2: 邮箱 + API密钥
CONFLUENCE_API_MAIL=your-email@example.com
CONFLUENCE_API_KEY=your_api_key_here
编辑Claude Desktop配置文件:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"confluence": {
"command": "node",
"args": ["D:\\confluence-mcp-server\\build\\index.js"],
"env": {
"CONFLUENCE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_PERSONAL_TOKEN": "your_token_here"
}
}
}
}
使用CQL搜索Confluence页面。
参数
cql (必填): CQL查询字符串limit (选填): 返回结果的数量,默认为10示例:
{
"cql": "type=page and space=DEV and title~\"API\"",
"limit": 5
}
返回格式:
{
"size": 5,
"limit": 5,
"results": [
{
"id": "123456",
"type": "page",
"status": "current",
"title": "API 文档",
"space": "DEV",
"version": 12,
"lastModified": "2025-01-15T10:30:00.000+08:00",
"url": "https://your-domain.atlassian.net/wiki/pages/viewpage.action?pageId=123456"
}
]
}
检索指定页面的内容,并自动解析表格数据。
参数
pageId (必填): Confluence页面ID示例:
{
"pageId": "123456"
}
返回格式(包括表格):
{
"id": "123456",
"type": "page",
"status": "current",
"title": "模块接口文档",
"space": {
"key": "DEV",
"name": "开发团队"
},
"version": {
"number": 15,
"when": "2025-01-15T10:30:00.000+08:00",
"by": "张三"
},
"url": "https://...",
"tables": [
{
"headers": ["功能名称", "负责人", "状态"],
"rows": [
{
"功能名称": "用户认证",
"负责人": "张三",
"状态": "完成"
},
{
"功能名称": "数据同步",
"负责人": "李四",
"状态": "进行中"
}
]
}
]
}
返回格式(无表格):
{
"id": "123456",
"title": "普通文档",
"content": "<p>原始 HTML 内容...</p>"
}
更新Confluence页面内容。
参数
pageId (必填): 页面IDcontent (必填): 新内容,HTML格式title (选填): 新标题示例:
{
"pageId": "123456",
"content": "<p>更新后的内容</p>",
"title": "新标题(可选)"
}
-- 搜索特定空间的页面
type=page and space=DEV
-- 按标题模糊搜索
type=page and title~"接口文档"
-- 搜索最近修改的页面
type=page and lastModified >= "2025-01-01"
-- 搜索特定作者创建的页面
type=page and creator="username"
-- 组合查询
type=page and space=DEV and title~"API" and lastModified >= "2025-01-01"
更多CQL语法,请参阅Confluence CQL文档。
# 测试连接
node test-connection.js
# 测试页面访问
node test-page-access.js
# 测试优化后的输出
node test-parsed-output.js
# 监视文件变化并自动编译
npm run watch
# 使用 MCP Inspector 调试
npm run inspector
confluence-mcp-server/
├── src/
│ └── index.ts # 主服务器代码
├── build/ # 编译后的 JavaScript
├── test-connection.js # 连接测试脚本
├── test-page-access.js # 页面访问测试
├── test-parsed-output.js # 输出优化测试
├── package.json
├── tsconfig.json
└── README.md
此服务器对Confluence API返回的数据进行了如下优化:
_expandable、_links等内部元数据<ac:task-list>、<ac:link>content字段调试MIT许可证
欢迎提交Issue和Pull Requests!