Confluence文档交互服务器

一个集成Confluence与AI助手的协议服务器,支持自然语言交互和文档管理功能。

  • by alirezarezvani
  • TypeScript
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 alirezarezvani/confluence-mcp-server

使用说明

汇流MCP服务器

一个模型上下文协议(MCP)服务器,将Confluence与Claude Desktop和其他人工智能助手集成在一起,实现了与Confluence文档的自然语言交互。

🚀 特性

  • 搜索页面:使用自然语言或CQL查询查找文档
  • 内容检索:获取保留格式的完整页面内容
  • 太空探索:列出并浏览您的Confluence空间
  • 页面层次结构:探索页面之间的父子关系
  • 基于标题的搜索:按完全匹配的标题查找页面
  • 实时集成:与Claude Desktop直接集成,实现无缝的人工智能辅助

📋 先决条件

  • Node.js (v18.0.0或更高版本)
  • npm (v8.0.0或更高版本)
  • 汇流云 具有API访问权限的帐户
  • 克劳德桌面 (用于AI集成)

🔧 安装

选项1:全局安装(推荐)

# Clone the repository
git clone https://github.com/alirezarezvani/confluence-mcp-server.git
cd confluence-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Install globally for easy access
npm run install-global

选项2:本地安装

# Clone the repository
git clone https://github.com/alirezarezvani/confluence-mcp-server.git
cd confluence-mcp-server

# Install dependencies and build
npm install
npm run build

⚙️ 配置

1.获取Confluence API凭据

  1. API代币:

  2. 空格键:

    • 导航到您的Confluence空间
    • 检查URL: https://your-org.atlassian.net/wiki/spaces/SPACEKEY/
    • 这 SPACEKEY 这就是你需要的
  3. 基本URL:

    • 通常 https://your-org.atlassian.net (无 /wiki)

2.环境设置

创建一个 .env 项目根目录中的文件:

CONFLUENCE_BASE_URL=https://your-org.atlassian.net
CONFLUENCE_EMAIL=your-email@company.com
CONFLUENCE_API_TOKEN=your-api-token-here
CONFLUENCE_SPACE_KEY=YOUR_SPACE_KEY

3.验证配置

# Test your environment variables
npm run validate-env

# Test the server connection
npm start

🤖 Claude桌面集成

配置文件位置

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

配置选项

选项1:全局安装

{
  "mcpServers": {
    "confluence": {
      "command": "confluence-mcp",
      "env": {
        "CONFLUENCE_BASE_URL": "https://your-org.atlassian.net",
        "CONFLUENCE_EMAIL": "your-email@company.com",
        "CONFLUENCE_API_TOKEN": "your-api-token",
        "CONFLUENCE_SPACE_KEY": "YOUR_SPACE_KEY"
      }
    }
  }
}

选项2:本地安装

{
  "mcpServers": {
    "confluence": {
      "command": "node",
      "args": ["/full/path/to/confluence-mcp-server/dist/confluence-mcp-server.js"],
      "env": {
        "CONFLUENCE_BASE_URL": "https://your-org.atlassian.net",
        "CONFLUENCE_EMAIL": "your-email@company.com",
        "CONFLUENCE_API_TOKEN": "your-api-token",
        "CONFLUENCE_SPACE_KEY": "YOUR_SPACE_KEY"
      }
    }
  }
}

激活

  1. 保存配置文件
  2. 完全重新启动克劳德桌面(Cmd+Q 然后重新打开)
  3. 在Claude Desktop界面中查找MCP工具

🛠️ 可用工具

1. 搜索_影响_页面

使用文本查询或CQL搜索页面。

使用示例:

  • “在Confluence中搜索“API文档”
  • “查找有关React开发的页面”
  • “查找故障排除指南”

2. get_page_content

检索特定页面的完整内容。

使用示例:

  • “获取页面ID 12345的内容”
  • “显示“安装指南”页面中的内容”

3. list_space_pages

列出Confluence空间中的所有页面。

使用示例:

  • “列出我们Confluence空间中的所有页面”
  • “显示最近的25页”

4. get_page层次结构

探索父子页面关系。

使用示例:

  • “显示“文档”下的所有子页”
  • “架构部分的子页面是什么?”

5. get_page_by_title

按完全匹配的标题查找页面。

使用示例:

  • “查找标题为“开发工作流”的页面”
  • “获取‘入职检查表’页面”

💬 使用示例

团队协作

"Help me find our deployment process documentation"
"What's the latest information about our API endpoints?"
"Show me all pages related to the mobile app project"
"Get me the content from our coding standards page"

项目管理

"Find all documentation related to the new feature"
"What's our current architecture documentation saying about microservices?"
"Show me the troubleshooting guides for production issues"
"List all pages updated in the last month"

开发工作流程

"Search for Docker configuration examples"
"Find our Git workflow documentation"
"What's in our testing guidelines page?"
"Show me the API integration examples"

🔧 发展

脚本

# Development with auto-reload
npm run dev

# Build TypeScript to JavaScript
npm run build

# Run the built server
npm start

# Watch for changes and auto-restart
npm run watch

# Clean build directory
npm run clean

# Validate environment variables
npm run validate-env

# Run tests
npm test

# Run specific test file
npm test -- tests/path/to/test.ts

项目结构

confluence-mcp-server/
├── src/
│   ├── confluence-mcp-server.ts  # Main server implementation
│   ├── cache/                    # Caching implementation
│   │   ├── CacheManager.ts       # Generic cache management
│   │   └── ConfluenceCache.ts    # Confluence-specific caching
│   └── monitoring/               # Performance monitoring
│       └── PerformanceMonitor.ts # Performance tracking and metrics
├── tests/
│   ├── confluence-mcp-server.test.ts  # Main server tests
│   ├── integration/              # Integration tests
│   │   └── mcp-tools.test.ts     # MCP tools integration tests
│   ├── cache/                    # Cache tests
│   │   └── CacheManager.test.ts  # Cache manager tests
│   ├── monitoring/               # Monitoring tests
│   │   └── PerformanceMonitor.test.ts # Performance monitor tests
│   └── utils/                    # Test utilities
│       └── test-utils.ts         # Mock implementations and helpers
├── dist/                         # Compiled JavaScript (after build)
├── package.json                  # Project dependencies and scripts
├── tsconfig.json                 # TypeScript configuration
├── jest.config.js                # Jest test configuration
├── .env                          # Environment variables (create this)
├── .env.test                     # Test environment variables
├── .gitignore                    # Git ignore rules
└── README.md                     # This file

🧪 测试

该项目包括一个使用Jest的全面测试套件。测试涵盖了MCP服务器功能的单元测试和集成测试。

运行测试

# Run all tests
npm test

# Run specific test file
npm test -- tests/cache/CacheManager.test.ts

# Run tests with coverage report
npm test -- --coverage

测试结构

  • 单元测试:单独测试单个组件
  • 集成测试:测试MCP工具及其与Confluence API的相互作用
  • 模拟测试:使用mock实现来模拟Confluence API响应

测试环境

测试使用单独的 .env.test 环境变量文件。运行测试时会自动设置测试环境。

最近的改进

  • 修复了测试导入中的路径问题
  • 通过更好的边缘案例处理改进了CacheManager的实现
  • 增强的性能监视器,具有更准确的指标
  • 增加了适当的测试数据准备,以获得一致的测试结果
  • 更新了ES模块支持的Jest配置

🚨 故障排除

常见问题

“权限被拒绝”错误

chmod +x dist/confluence-mcp-server.js

“缺少环境变量”

npm run validate-env

“无法连接到Confluence”

  1. 验证您的API令牌是否具有正确的权限
  2. 检查您的基本URL格式(没有尾随斜线)
  3. 确保您的电子邮件和空格键正确

“Claude Desktop无法识别MCP服务器”

  1. 检查配置文件路径
  2. 验证配置文件中的JSON语法
  3. 完全重新启动克劳德桌面
  4. 检查Claude Desktop日志是否有错误

调试模式

# Run with detailed logging
LOG_LEVEL=debug npm start

🔒 安全考虑

  • API代币:永远不要将API令牌提交到版本控制
  • 环境变量:使用 .env 文件并确保其安全
  • 权限:确保您的API令牌具有最低要求的权限
  • 网络:考虑对敏感的公司文档使用VPN

🤝 贡献

我们欢迎捐款!请查看我们的 贡献指南 了解详情。

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢

📞 支持

🗺️ 2025年第二季度/第三季度路线图

  • []支持多个Confluence空间
  • []页面创建和编辑功能
  • []评论和附件处理
  • []OAuth 2.0身份验证
  • [x] 缓存以提高性能
  • []Docker容器化
  • []Confluence服务器(内部部署)支持
  • [x] 全面的测试套件

由以下材料制成❤️ 靠近 Alireza Rezvani