使用说明
汇流MCP服务器
Confluence的模型上下文协议(MCP)服务器,使AI助手能够与Confluence云和数据中心实例进行交互。用。NET 10使用 基鲁基。MCP服务器。标准输入输出 图书馆。
特性
- ✅ 双重部署支持:同时使用Confluence Cloud(API令牌+电子邮件)和Confluence Datacenter(PAT令牌)
- ✅ 页面管理:创建、读取、更新、删除、复制和移动页面
- ✅ 空间操作:列出、创建和管理空间
- ✅ 搜索:完全支持CQL(汇流查询语言)
- ✅ 评论:添加和管理页面评论
- ✅ 附件:列出和管理页面附件
- ✅ 标签:按标签添加、删除和搜索
- ✅ 博客文章:创建和管理博客文章
- ✅ 模板:使用模板创建页面
- ✅ 版本历史记录:访问页面历史记录和还原版本
- ✅ 权限:查看页面限制和空间权限
- ✅ 观看/关注:订阅页面和空间通知
先决条件
- .NET 10 SDK 或以后
- 汇流云或数据中心实例
- API凭据(请参阅配置部分)
安装
构建服务器
git clone <repository-url>
cd ConfluenceMcpServer
dotnet build -c Release
发布为可执行文件(推荐)
跨平台(需要.NET运行时):
dotnet publish -c Release -o ./publish
自包含的可执行文件(不需要.NET运行时):
# Windows
dotnet publish -c Release -r win-x64 --self-contained -o ./publish
# macOS (Intel)
dotnet publish -c Release -r osx-x64 --self-contained -o ./publish
# macOS (Apple Silicon)
dotnet publish -c Release -r osx-arm64 --self-contained -o ./publish
# Linux
dotnet publish -c Release -r linux-x64 --self-contained -o ./publish
发布后,您将获得:
ConfluenceMcpServer.exe(Windows)或ConfluenceMcpServer(macOS/Linux)-独立可执行文件ConfluenceMcpServer.dll-要求dotnet ConfluenceMcpServer.dll跑
配置
服务器使用环境变量进行配置:
| 变量 | 必填 | 描述 |
|---|---|---|
CONFLUENCE_BASE_URL |
是 | 您的Confluence实例URL |
CONFLUENCE_DEPLOYMENT_TYPE |
是的 | cloud 或 datacenter |
CONFLUENCE_API_TOKEN |
是 | API令牌(云)或PAT(数据中心) |
CONFLUENCE_EMAIL |
仅限云 | 与API令牌关联的电子邮件 |
汇流云设置
- 首选 Atlassian帐户设置
- 点击“创建API令牌”
- 复制令牌并设置环境变量:
export CONFLUENCE_BASE_URL="https://your-domain.atlassian.net/wiki"
export CONFLUENCE_DEPLOYMENT_TYPE="cloud"
export CONFLUENCE_API_TOKEN="your-api-token"
export CONFLUENCE_EMAIL="your-email@example.com"
汇流数据中心设置
- 转到您的Confluence个人资料→ 个人访问令牌
- 创建具有适当权限的新令牌
- 设置环境变量:
export CONFLUENCE_BASE_URL="https://confluence.your-company.com"
export CONFLUENCE_DEPLOYMENT_TYPE="datacenter"
export CONFLUENCE_API_TOKEN="your-pat-token"
客户端配置
克劳德桌面版
添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
视窗: %APPDATA%\Claude\claude_desktop_config.json
使用可执行文件(推荐)
{
"mcpServers": {
"confluence": {
"command": "/path/to/publish/ConfluenceMcpServer.exe",
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
使用DLL(需要.NET运行时)
{
"mcpServers": {
"confluence": {
"command": "dotnet",
"args": ["/path/to/publish/ConfluenceMcpServer.dll"],
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
Visual Studio GitHub副本
要在Visual Studio中与GitHub Copilot一起使用:
-
发布服务器 作为可执行文件:
dotnet publish -c Release -r win-x64 --self-contained -o ./publish -
配置MCP服务器 在Visual Studio中:
- 首选 工具 → 选项 → GitHub Copilot → MCP服务器
- 或添加到您的
.vs/mcp.json解决方案中的文件:
使用可执行文件(推荐)
{
"servers": {
"confluence": {
"command": "C:/path/to/publish/ConfluenceMcpServer.exe",
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
使用DLL(需要.NET运行时)
{
"servers": {
"confluence": {
"command": "dotnet",
"args": ["C:/path/to/publish/ConfluenceMcpServer.dll"],
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
- 替代:在以下位置使用用户级配置
%USERPROFILE%\.copilot\mcp.json
风帆冲浪(Codeium)
添加到您的Windsurf MCP配置中:
macOS: ~/.codeium/windsurf/mcp_config.json
视窗: %USERPROFILE%\.codeium\windsurf\mcp_config.json
使用可执行文件(推荐)
{
"mcpServers": {
"confluence": {
"command": "/path/to/publish/ConfluenceMcpServer.exe",
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
使用DLL(需要.NET运行时)
{
"mcpServers": {
"confluence": {
"command": "dotnet",
"args": ["/path/to/publish/ConfluenceMcpServer.dll"],
"env": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
}
}
数据中心示例
{
"mcpServers": {
"confluence": {
"command": "/path/to/publish/ConfluenceMcpServer.exe",
"env": {
"CONFLUENCE_BASE_URL": "https://confluence.your-company.com",
"CONFLUENCE_DEPLOYMENT_TYPE": "datacenter",
"CONFLUENCE_API_TOKEN": "your-pat-token"
}
}
}
}
无烟煤(反重力/Claude API)
对于定制Claude API集成或Antigravity平台:
- 发布服务器 作为可执行文件
- 启动服务器 作为stdio传输的子流程
- 通过MCP协议连接 通过标准输入/标准输出
Python集成示例
import subprocess
import json
import os
# Start the MCP server using executable
process = subprocess.Popen(
["/path/to/publish/ConfluenceMcpServer.exe"], # or ConfluenceMcpServer on macOS/Linux
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
env={
**os.environ,
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
)
# Or using DLL with dotnet runtime
process = subprocess.Popen(
["dotnet", "/path/to/publish/ConfluenceMcpServer.dll"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
env={
**os.environ,
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
)
# Send MCP initialize request
request = {
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "my-client", "version": "1.0.0"}
}
}
process.stdin.write(json.dumps(request).encode() + b'\n')
process.stdin.flush()
反重力配置
对于 反重力 具体来说,在代理设置中配置:
使用可执行文件:
{
"mcp_servers": [
{
"name": "confluence",
"transport": "stdio",
"command": "/path/to/publish/ConfluenceMcpServer.exe",
"environment": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
]
}
使用DLL:
{
"mcp_servers": [
{
"name": "confluence",
"transport": "stdio",
"command": "dotnet",
"args": ["/path/to/publish/ConfluenceMcpServer.dll"],
"environment": {
"CONFLUENCE_BASE_URL": "https://your-domain.atlassian.net/wiki",
"CONFLUENCE_DEPLOYMENT_TYPE": "cloud",
"CONFLUENCE_API_TOKEN": "your-api-token",
"CONFLUENCE_EMAIL": "your-email@example.com"
}
}
]
}
可用工具
页面操作
| 工具 | 说明 |
|---|---|
confluence_get_page |
按ID获取包含可选正文内容的页面 |
confluence_get_page_by_title |
按标题和空格键获取页面 |
confluence_create_page |
创建新页面 |
confluence_update_page |
更新现有页面 |
confluence_delete_page |
删除页面(垃圾或清除) |
confluence_get_page_children |
获取子页面 |
confluence_get_page_ancestors |
获取父页面 |
confluence_get_page_history |
获取版本历史记录 |
confluence_get_page_version |
获取特定版本 |
confluence_copy_page |
将页面复制到新位置 |
confluence_move_page |
将页面移动到新父级 |
空间操作
| 工具 | 说明 |
|---|---|
confluence_list_spaces |
列出所有可访问的空间 |
confluence_get_space |
获取空间详细信息 |
confluence_create_space |
创建新空间 |
confluence_delete_space |
删除空格 |
confluence_get_space_content |
获取空间中的所有内容 |
搜索操作
| 工具 | 说明 |
|---|---|
confluence_search |
使用CQL搜索 |
confluence_search_content |
简单文本搜索 |
confluence_search_by_label |
按标签搜索 |
评论操作
| 工具 | 说明 |
|---|---|
confluence_get_page_comments |
在页面上获取评论 |
confluence_add_comment |
添加评论 |
confluence_delete_comment |
删除评论 |
附件操作
| 工具 | 说明 |
|---|---|
confluence_get_attachments |
获取页面附件 |
confluence_get_attachment_info |
获取附件详细信息 |
confluence_delete_attachment |
删除附件 |
标签操作
| 工具 | 说明 |
|---|---|
confluence_get_labels |
在页面上获取标签 |
confluence_add_labels |
向页面添加标签 |
confluence_remove_label |
删除标签 |
用户操作
| 工具 | 说明 |
|---|---|
confluence_get_current_user |
获取经过身份验证的用户 |
confluence_search_users |
搜索用户 |
confluence_get_user_content |
获取用户内容 |
博客帖子操作
| 工具 | 说明 |
|---|---|
confluence_create_blog_post |
创建博客文章 |
confluence_get_blog_posts |
在空间中获取博客文章 |
模板操作
| 工具 | 说明 |
|---|---|
confluence_get_templates |
获取可用模板 |
confluence_create_page_from_template |
从模板创建页面 |
权限操作
| 工具 | 说明 |
|---|---|
confluence_get_page_restrictions |
获取页面限制 |
confluence_get_space_permissions |
获取空间权限 |
观察/跟踪操作
| 工具 | 说明 |
|---|---|
confluence_watch_page |
观看页面 |
confluence_unwatch_page |
停止观看页面 |
confluence_watch_space |
观看空间 |
内容属性
| 工具 | 说明 |
|---|---|
confluence_get_content_properties |
获取自定义属性 |
confluence_set_content_property |
设置自定义属性 |
最近的内容
| 工具 | 说明 |
|---|---|
confluence_get_recent_content |
获取最近修改的内容 |
confluence_get_my_recent_work |
获取当前用户最近的工作 |
可用资源
配置
| 资源URI | 描述 |
|---|---|
confluence://config |
当前配置(已消毒) |
页面资源
| 资源URI | 描述 |
|---|---|
confluence://page/{pageId} |
页面详细信息 |
confluence://page/{pageId}/body |
页面正文内容(HTML) |
confluence://page/{pageId}/children |
子页面 |
confluence://page/{pageId}/comments |
页面评论 |
confluence://page/{pageId}/attachments |
页面附件 |
confluence://page/{pageId}/labels |
页面标签 |
confluence://page/{pageId}/history |
页面版本历史记录 |
空间资源
| 资源URI | 描述 |
|---|---|
confluence://spaces |
所有无障碍空间 |
confluence://space/{spaceKey} |
空间详细信息 |
confluence://space/{spaceKey}/pages |
空间中的所有页面 |
confluence://space/{spaceKey}/blogposts |
空间博客文章 |
confluence://space/{spaceKey}/root-pages |
顶级页面 |
confluence://space/{spaceKey}/templates |
空间模板 |
用户资源
| 资源URI | 描述 |
|---|---|
confluence://current-user |
经过身份验证的用户信息 |
confluence://my-recent-work |
用户最近的活动 |
搜索资源
| 资源URI | 描述 |
|---|---|
confluence://search/{query} |
搜索结果 |
confluence://label/{label} |
按标签列出的内容 |
最近的内容
| 资源URI | 描述 |
|---|---|
confluence://recent-pages |
最近修改的页面 |
confluence://recent-blogposts |
最近的博客文章 |
confluence://templates |
全局模板 |
用法示例
配置后,您可以询问您的AI助手:
页面管理
- “在DEV空间中创建名为“API文档”的新页面”
- “获取第123456页的内容”
- “更新space HR中标题为“会议笔记”的页面”
- “将第123456页复制到存档空间”
- “将第123456页移至第789012页下”
搜索和发现
- “搜索包含“部署指南”的页面”
- “查找标签为“架构”的所有页面”
- “列出开发空间中的所有页面”
- “显示最近修改的页面”
评论与合作
- “在第123456页添加一条评论,说‘很棒的文档!’”
- “获取API文档页上的所有注释”
- “关注架构空间以获取更新”
空间管理
- “列出我有权访问的所有空间”
- “获取DEV空间的详细信息”
- “使用密钥Alpha创建一个名为“Project Alpha”的新空间”
标签和组织
- 将“重要、已审阅”标签添加到第123456页
- “查找所有标记为“草稿”的页面”
- “从第123456页删除“过时”标签”
模板
- “列出DEV空间中的可用模板”
- “从“会议笔记”模板创建新页面”
CQL查询示例
这 confluence_search 该工具接受CQL查询:
# Find pages in a specific space
type=page AND space=DEV
# Full-text search
text~"deployment guide"
# Pages modified recently
type=page AND lastmodified>=now("-7d")
# Pages with specific labels
label="architecture" AND label="approved"
# Pages created by specific user
creator=currentUser() AND type=page
# Blog posts from this year
type=blogpost AND created>=2024-01-01
# Combined complex query
type=page AND space IN (DEV, PROD) AND label="api" AND lastmodified>=now("-30d") ORDER BY lastmodified DESC
汇流存储格式(XHTML)
创建或更新页面时,请使用Confluence存储格式(XHTML):
<h1>Heading</h1>
<p>This is a paragraph with <strong>bold</strong> and <em>italic</em> text.</p>
<ul>
<li>Bullet point 1</li>
<li>Bullet point 2</li>
</ul>
<ol>
<li>Numbered item 1</li>
<li>Numbered item 2</li>
</ol>
<ac:structured-macro ac:name="code">
<ac:parameter ac:name="language">python</ac:parameter>
<ac:plain-text-body><![CDATA[print("Hello, World!")]]></ac:plain-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name="info">
<ac:rich-text-body>
<p>This is an info panel</p>
</ac:rich-text-body>
</ac:structured-macro>
故障排除
常见问题
“未设置CONFLUENCE_BASE_URL环境变量”
- 确保配置了所有必需的环境变量
- 对于云,包括
/wiki在URL中:https://your-domain.atlassian.net/wiki
“401未经授权”
- 验证您的API令牌/PAT是否正确且未过期
- 对于云:确保电子邮件与Atlassian帐户匹配
- 对于数据中心:确保PAT具有所需的权限
“404未找到”
- 检查页面/空间ID或键是否正确
- 验证您是否有权访问该内容
“连接被拒绝”
- 检查CONFLUENCE_BASE_URL是否可以从您的计算机访问
- 验证没有防火墙/代理阻止连接
服务器未启动
- 确保。NET 10 SDK已安装:
dotnet --version - 先尝试构建:
dotnet build
调试模式
要查看详细的MCP通信:
# Run with output logging
dotnet run 2>&1 | tee mcp-debug.log
项目结构
ConfluenceMcpServer/
├── Confluence_MCP.csproj # Project file with NuGet reference
├── Program.cs # Server entry point
├── README.md # This file
├── Configuration/
│ └── ConfluenceConfiguration.cs # Environment-based config
├── Services/
│ └── ConfluenceClient.cs # HTTP client for Confluence API
├── Tools/
│ └── ConfluenceTools.cs # MCP tool implementations (45+ tools)
└── Resources/
└── ConfluenceResources.cs # MCP resource implementations (20+ resources)
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
贡献
欢迎投稿!请随时提交问题和拉取请求。
致谢
- 建于 基鲁基。MCP服务器。标准输入输出
- 实施 模型上下文协议