Confluence MCP Server
Enables reading, searching, creating, updating, and deleting Confluence pages and managing spaces via natural language, with automatic Markdown conversion.
README
Confluence MCP Server
一个用于 Confluence Server/Data Center 的 Model Context Protocol (MCP) Server,提供完整的知识库读写能力。
功能特性
- 搜索页面: 使用 CQL 查询语言搜索 Confluence 页面
- 读取页面: 获取页面详情,自动转换为 Markdown 格式
- 创建页面: 支持 Markdown 和原生格式创建新页面
- 更新页面: 更新现有页面的标题和内容
- 删除页面: 删除指定页面
- 空间管理: 列出空间、获取空间内容、获取子页面结构
- 格式转换: 支持 Confluence Storage Format 与 Markdown 互转
安装
pip install -e .
配置
创建 .env 文件或设置环境变量:
CONFLUENCE_BASE_URL=https://your-confluence-domain.com/confluence
CONFLUENCE_USERNAME=your-email@example.com
CONFLUENCE_API_TOKEN=your-api-token-or-password
CONFLUENCE_API_VERSION=latest
CONFLUENCE_TIMEOUT=30
使用
启动 MCP Server
confluence-mcp-server --url https://your-confluence/confluence --username user@example.com --api-token your-token
或使用环境变量:
source .env
confluence-mcp-server
命令行参数
confluence-mcp-server --help
Options:
--url TEXT Confluence base URL
--username TEXT Confluence username/email
--api-token TEXT Confluence API token or password
--api-version TEXT API version (default: latest)
--timeout INTEGER Request timeout in seconds
-v, --version Show the version and exit.
--help Show this message and exit.
支持的工具
内容操作
search_pages: 使用 CQL 搜索页面get_page: 根据页面ID获取页面详情create_page: 创建新页面update_page: 更新现有页面delete_page: 删除页面get_page_by_title: 根据标题搜索页面
空间操作
list_spaces: 列出所有空间get_space: 获取空间详情get_space_content: 获取空间中的内容列表get_child_pages: 获取父页面的子页面
CQL 查询示例
text ~ "用户登录" AND space = "TECH"
title ~ "API" AND type = "page"
space = "PRD" AND label = "2024"
多 Agent 使用教程
在 TRAE 中使用
方式一:通过项目技能导入(推荐)
- 打开 TRAE IDE
- 在项目面板中添加
confluence-skill项目目录 - TRAE 会自动识别
SKILL.md和mcp.json配置 - 在对话中直接使用自然语言触发技能
方式二:手动配置 MCP Server
- 在终端启动 MCP Server:
cd /path/to/confluence-skill
source .venv/bin/activate
confluence-mcp-server
- 在 TRAE 的设置中添加 MCP Server:
- 名称:
confluence-mcp-server - URL:
http://localhost:8000
- 名称:
在 Cursor 中使用
- 确保项目目录中有
.cursor/mcp.json配置文件 - Cursor 会自动读取配置并启动 MCP Server
- 在对话中使用
@confluence-mcp-server触发技能
.cursor/mcp.json 配置示例:
{
"name": "confluence-mcp-server",
"command": "python",
"args": ["-m", "src.main"],
"env": {
"CONFLUENCE_BASE_URL": "${CONFLUENCE_BASE_URL}",
"CONFLUENCE_USERNAME": "${CONFLUENCE_USERNAME}",
"CONFLUENCE_API_TOKEN": "${CONFLUENCE_API_TOKEN}"
},
"description": "Confluence MCP Server for reading and writing Confluence pages"
}
在 Claude Code 中使用
方式一:通过 CLAUDE.md 配置
- 在项目根目录创建或编辑
CLAUDE.md文件 - 添加以下配置:
---
skills:
- name: confluence-skill
type: mcp
server:
command: python
args: ["-m", "src.main"]
env:
CONFLUENCE_BASE_URL: "${CONFLUENCE_BASE_URL}"
CONFLUENCE_USERNAME: "${CONFLUENCE_USERNAME}"
CONFLUENCE_API_TOKEN: "${CONFLUENCE_API_TOKEN}"
---
# Confluence 知识库技能
使用 Confluence 技能可以搜索、读取、创建和更新 Confluence 文档。
- 在对话中直接使用自然语言触发:
- "帮我搜索 Java 编码规范文档"
- "获取页面 63777422 的内容"
方式二:手动启动 MCP Server
- 启动 MCP Server:
cd /path/to/confluence-skill
source .venv/bin/activate
confluence-mcp-server
- 在 Claude Code 设置中添加 MCP Server:
- 打开 Claude Code 设置
- 找到 MCP Servers 配置
- 添加新服务器:
http://localhost:8000
在 Codex 中使用
- 在项目目录中创建
.codex/mcp.json配置文件:
{
"servers": [
{
"name": "confluence-mcp-server",
"type": "http",
"url": "http://localhost:8000",
"description": "Confluence MCP Server"
}
]
}
- 启动 MCP Server:
cd /path/to/confluence-skill
source .venv/bin/activate
confluence-mcp-server
- 在 Codex 对话中使用
@confluence-mcp-server触发技能
在 OpenCode 中使用
- 在项目目录中创建
.opencode/mcp.json配置文件:
{
"name": "confluence-mcp-server",
"command": "python",
"args": ["-m", "src.main"],
"env": {
"CONFLUENCE_BASE_URL": "${CONFLUENCE_BASE_URL}",
"CONFLUENCE_USERNAME": "${CONFLUENCE_USERNAME}",
"CONFLUENCE_API_TOKEN": "${CONFLUENCE_API_TOKEN}"
},
"description": "Confluence MCP Server for reading and writing Confluence pages"
}
- OpenCode 会自动识别配置并启动 MCP Server
- 在对话中使用
@confluence-mcp-server触发技能
使用 MCP Python SDK
from mcp.stdio_client import StdioClient
async def main():
async with StdioClient(command="python", args=["-m", "src.main"]) as client:
# 搜索页面
results = await client.call_tool("search_pages", {"cql": "text ~ 'Java'", "limit": 5})
print(results)
# 获取页面内容
page = await client.call_tool("get_page", {"page_id": "63777422"})
print(page.get("title"))
print(page.get("body", {}).get("markdown"))
# 创建页面
new_page = await client.call_tool(
"create_page",
{
"title": "新文档标题",
"space_key": "TECH",
"content": "# 新文档\n\n内容描述",
"content_format": "markdown"
}
)
print(new_page)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
使用 HTTP API
MCP Server 默认在 http://localhost:8000 提供 HTTP 接口。
列出所有工具
curl http://localhost:8000/mcp/list_tools
调用工具(POST)
curl -X POST http://localhost:8000/mcp/call_tool \
-H "Content-Type: application/json" \
-d '{
"name": "search_pages",
"arguments": {
"cql": "text ~ \"Java\"",
"limit": 5
}
}'
在自定义 Agent 中集成
import requests
class ConfluenceSkillClient:
def __init__(self, base_url="http://localhost:8000"):
self.base_url = base_url
def search_pages(self, cql, limit=20):
return self._call_tool("search_pages", {"cql": cql, "limit": limit})
def get_page(self, page_id):
return self._call_tool("get_page", {"page_id": page_id})
def create_page(self, title, space_key, content, content_format="markdown"):
return self._call_tool(
"create_page",
{"title": title, "space_key": space_key, "content": content, "content_format": content_format}
)
def _call_tool(self, tool_name, arguments):
response = requests.post(
f"{self.base_url}/mcp/call_tool",
json={"name": tool_name, "arguments": arguments}
)
return response.json()
client = ConfluenceSkillClient()
results = client.search_pages("text ~ '技术文档'")
print(results)
环境变量配置方式
方式一:使用 .env 文件
cp .env.example .env
# 编辑 .env 文件配置
source .env
confluence-mcp-server
方式二:命令行参数
confluence-mcp-server \
--url https://docs.jk.com \
--username zhengzih \
--api-token your-password
方式三:系统环境变量
export CONFLUENCE_BASE_URL=https://docs.jk.com
export CONFLUENCE_USERNAME=zhengzih
export CONFLUENCE_API_TOKEN=your-password
confluence-mcp-server
技术栈
- Python 3.10+
- MCP SDK (
mcp[cli]) - Requests
- BeautifulSoup4
- Markdown
- Click
许可证
MIT License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.