自建Jira和汇流MCP服务器
MCP(模型上下文协议)服务器,用于自托管Jira服务器/数据中心8.x和Confluence服务器/数据中央6.x。
特性
汇流工具
confluence_get_spaces-获取所有Confluence空间的列表confluence_get_page-按ID获取包含完整内容的页面confluence_search_pages-使用CQL(汇流查询语言)搜索页面confluence_create_page-使用存储格式内容创建新页面
Jira工具
jira_get_issue-按密钥获取问题jira_search_issues-使用JQL(Jira查询语言)搜索问题jira_create_issue-创建新问题
需求
- Python 3.12+
- 自托管Jira服务器/数据中心8.x
- 自托管Confluence服务器/数据中心6.x
- 两个系统的API令牌
安装
- 克隆存储库:
git clone
cd selfhosted-jira-confluence-mcp- 创建虚拟环境并安装依赖关系:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- 创建
.env使用您的凭据文件:
# Confluence Configuration
CONFLUENCE_BASE_URL=https://confluence.example.com
CONFLUENCE_USERNAME=your-username
CONFLUENCE_API_TOKEN=your-api-token
# Jira Configuration
JIRA_BASE_URL=https://jira.example.com
JIRA_USERNAME=your-username
JIRA_API_TOKEN=your-api-token连接到游标
- 将配置添加到
~/.cursor/mcp.json:
{
"mcpServers": {
"atlassian-jira-confluence": {
"command": "/absolute/path/to/your/project/venv/bin/python",
"args": [
"/absolute/path/to/your/project/server.py"
],
"cwd": "/absolute/path/to/your/project"
}
}
}- 完全重新启动游标:
- 在macOS上: ⌘ + Q 并重新开放 - 在Windows/Linux上:关闭并重新打开应用程序
- MCP服务器将自动启动,并可在聊天中使用
使用示例
汇流
获取空间列表:
Use confluence_get_spaces to get all spaces搜索页面:
Find all pages in DEV space: space = "DEV" AND type = "page"获取特定页面:
Show page with ID 12345创建新页面:
Create page in space "DEV" with title "My New Page" and content "
Hello World
"Jira
搜索问题:
Find all open tasks in L2S project: project = L2S AND statusCategory != Done获取具体问题:
Show details of issue L2S-123创建新问题:
Create task in project L2S with summary "Fix bug"截图演示查询
汇流查询
1.获取所有汇流空间:
Show me all Confluence spaces available2.查找具体文件:
Find all pages about Karpenter in the ENG space3.查找最近更新的页面:
Search for pages in DEV space that were modified in the last 7 days4.获取页面内容:
Show me the content of Confluence page with ID 1234565.创建文档页面:
Create a new Confluence page in the ENG space titled "API Integration Guide" with introduction section6.按标题查找页面:
Find all pages with "deployment" in the title across all spacesJira查询
1.查找未完成的任务:
Show me all open tasks in the L2S project that are not done2.发现高优先级错误:
Find all high-priority bugs in INFRA project that are in progress3.获取具体问题细节:
Show me detailed information about issue L2S-4564.发现最近产生的问题:
Find all issues created in the last 3 days in the DEV project5.创建一个新bug:
Create a bug in project INFRA with summary "API timeout on user authentication endpoint"6.找到分配的工作:
Show all tasks assigned to me in the L2S project that are in Todo status7.按构成部分查找问题:
Find all issues in CLOUD project with component "Kubernetes" that are not closed8.Sprint相关搜索:
Show all user stories in active sprint for project DEVOPS组合使用示例
1.对照:
Find Jira issues mentioned in Confluence pages in the DOC space2.文件跟踪:
Check if Confluence page 78910 mentions any open Jira issues from project L2S3.创建链接内容:
Create a Confluence page documenting the solution for Jira issue INFRA-123测试
运行测试脚本以验证Confluence连接:
source venv/bin/activate
python test_spaces.py这将获取并显示所有可用的Confluence空间。
发展
选项1:直接执行Python
可以直接运行服务器进行测试:
source venv/bin/activate
python server.py这将以STDIO模式启动MCP服务器。服务器将等待stdin上的输入,并将响应写入stdout。按 Ctrl+C 停止。
备注:直接运行时,服务器需要stdin上的MCP协议消息。对于Confluence/Jira的实际测试,请使用下面的集成方法或测试脚本。
选项2:使用Cursor进行集成测试
对于实际测试,请在Cursor中配置服务器(请参阅上面的“连接到Cursor”部分)。Cursor启动时,服务器将自动启动,并可通过AI聊天界面使用。
这是使用实际Confluence和Jira操作测试服务器的推荐方法。
选项3:使用MCP CLI的开发模式(可选)
如果你有 mcp 全局安装的CLI工具:
~/.default-venv/bin/mcp dev server.py这将以开发模式启动MCP服务器,并使用检查器UI进行调试。
API参考资料
Confluence REST API
- 基础路径:
/rest/api - 兼容:Confluence服务器/数据中心6.14.1+
- 官方文件
Jira REST API
- 基础路径:
/rest/api/2 - 兼容:Jira服务器/数据中心8.8.0+
- 官方文件
安全说明
- 将凭据存储在
.envfile(永远不要提交此文件) - 使用API令牌而不是密码
- 这
.env文件被git忽略(请参见.gitignore) - API令牌可以通过Atlassian配置文件设置生成
故障排除
MCP服务器未启动:
- 检查一下
.env文件存在并且包含有效凭据 - 验证中的Python路径
mcp.json是正确和绝对的 - 检查Cursor开发人员控制台(
⌘ + Shift + I)对于错误
连接错误:
- 验证基本URL是否正确(没有尾随斜线)
- 检查Jira/Confluence服务器的网络连接
- 确保API令牌有效且未过期
光标中未显示的工具:
- 完全重新启动游标
- 检查光标首选项中的MCP设置
- 验证
mcp.json语法是有效的JSON
许可证
麻省理工学院
贡献
欢迎投稿!请随时打开问题或提交pull请求。
作者
伊戈尔·戈罗维
