Confluence MCP Server
Enables AI models to interact with Confluence knowledge bases by searching, reading, and creating pages through the Confluence REST API. It provides a suite of tools for space management, document retrieval, and content creation, including a mock mode for local testing.
README
Confluence MCP Demo
这个目录提供了一个最小可运行的 Confluence MCP Python demo,目标是先把整体链路打通,再逐步扩展成生产可用版本。
1. 我们需要哪些功能
如果要做一个真正可用的 Confluence MCP,建议按下面 3 个层次来设计。
A. 最小可用能力
这些功能足够支持“让大模型读取 Confluence 知识库并做基础写入”:
health用于确认 MCP 服务是否正常、当前连接的是mock还是real模式。list_spaces列出空间,帮助模型知道知识分区。list_pages按空间列出页面,支持基础浏览。get_page读取页面正文,至少返回body.storage。search_pages基于 CQL 搜索页面,是最核心的检索能力。create_page允许模型把整理结果或报告写回 Confluence。
B. 生产常用能力
如果后续要真正接入业务,通常还需要:
update_page更新页面内容,并处理版本号冲突。delete_page或archive_page清理无效内容时会用到。get_page_children支持文档树遍历。get_comments/add_comment便于做协作场景。get_attachments/upload_attachment很多资料以附件方式存在。get_labels/set_labels有助于主题归档与检索。
C. 工程化能力
要稳定服务给 MCP 客户端,还应补齐:
- 认证配置管理 使用 API Token,避免把密钥写死在代码中。
- 权限边界 例如默认只读,写操作单独开关。
- 错误处理与重试 包括限流、401、403、404、429、5xx。
- 内容格式转换
Confluence 常见的是
storage格式,很多模型更适合 Markdown。 - 观测性 增加请求日志、trace id、调用耗时。
- 结果裁剪 避免把超长正文一次性返回给模型。
2. 当前 demo 实现了什么
本 demo 已经实现以下 MCP 工具:
healthlist_spaceslist_pagesget_pagesearch_pagescreate_page
并且支持两种运行模式:
mock不依赖真实 Confluence,适合先演示流程。real通过 Confluence REST API 访问真实实例。
3. 文件说明
confluence_mcp_demo.pyMCP 服务主程序,包含 mock 客户端、真实 Confluence 客户端和工具注册逻辑。requirements.txtPython 依赖。env.example环境变量示例。
4. 安装与运行
安装依赖
cd /home/simon/simondisk1/NCAA2026/MCP_confluence
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
运行本地 demo
mock 模式下不需要真实 Confluence 账号:
python3 confluence_mcp_demo.py --mode mock --demo
启动 MCP Server
python3 confluence_mcp_demo.py --mode mock
切到真实 Confluence
先准备环境变量:
cp env.example .env
然后把其中的值改成真实配置,再运行:
python3 confluence_mcp_demo.py --mode real --demo
python3 confluence_mcp_demo.py --mode real
5. 示例代码
下面是直接调用业务层的演示思路,便于你理解 MCP 背后做了什么:
from confluence_mcp_demo import build_service
service = build_service(mode="mock")
print(service.list_spaces(limit=5))
print(service.list_pages(space_key="ENG", limit=5))
print(service.search_pages(cql='text ~ "API"', limit=5))
print(service.get_page(page_id="1002"))
print(
service.create_page(
space_key="ENG",
title="MCP Demo Page",
content="<p>Created from demo</p>",
)
)
6. AI Agent Client 示例
如果你希望写一个真正的 AI client 去调用 MCP server,本目录已经新增:
ai_agent_client_demo.py
这个脚本的设计目标是:
- 通过
stdio连接本地confluence_mcp_demo.py - 自动读取 MCP tools
- 把 tools 转成 OpenAI Chat Completions 兼容的
tools格式 - 用 HTTP
POST调用一个 AI 服务 URL - 让模型决定是否调用
search_pages、get_page等工具 - 把工具结果再回传给模型生成最终回答
运行方式
先准备环境变量:
cp env.example .env
填写以下几个关键值:
AI_CHAT_URL=https://api.openai.com/v1/chat/completions
AI_BEARER_TOKEN=your-token
AI_MODEL=gpt-4o-mini
MCP_MODE=mock
AGENT_USER_QUERY=请帮我搜索和API相关的Confluence页面,并总结页面标题。
然后运行:
python3 ai_agent_client_demo.py
说明
- 这个 agent 会自己拉起
confluence_mcp_demo.py --mode mock - 它使用
Authorization: Bearer <token>做鉴权 - 它直接向
AI_CHAT_URL发送 HTTPPOST - 只要你的 AI 服务兼容 OpenAI Chat Completions 请求格式即可替换
7. 后续建议
如果你准备把它变成真正可接 Cursor 或 Claude Desktop 的 MCP Server,下一步最值得补的是:
update_pageget_page_children- Markdown 和 Confluence Storage 格式互转
- 写操作权限开关
- 更精细的搜索与摘要裁剪
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.