mcpField
G
GitLab PR Analysis MCP Server

GitLab PR Analysis MCP Server

本地服务
github.com/CodeByWaqas版本控制084 周前更新

关于 GitLab PR Analysis MCP Server

GitLab PR Analysis MCP Server 将 GitLab 合并请求分析与 Confluence 文档结合,适用于需要审查变更并留存报告的团队。它可提取请求详情、分析代码变化,并将结果写入 Confluence。

主要功能

  1. 01获取合并请求详情
  2. 02分析代码变更
  3. 03生成变更统计与文件分析
  4. 04将分析结果存入 Confluence
  5. 05提供调试日志

适用场景

  1. 01审查合并请求中的代码变化
  2. 02汇总文件类型及变更明细
  3. 03将合并请求分析存档到 Confluence

MCP 相关

该 MCP 服务向 MCP 客户端提供 GitLab 合并请求详情获取、代码变更分析和 Confluence 存储工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

GitLab PR 分析 MCP 服务

本项目提供一个 MCP(Model Control Protocol)服务,可将 GitLab 合并请求分析与 Confluence 文档集成。它允许你获取合并请求详情、分析代码变更,并将结果保存到 Confluence 页面中。

功能

  • 获取 GitLab 合并请求详情
  • 分析合并请求中的代码变更
  • 生成详细报告,包括:
    • 合并请求基本信息
    • 代码变更统计
    • 文件类型分析
    • 文件变更详情
  • 将分析结果保存到 Confluence
  • 提供全面的日志记录,便于调试

前置条件

  • Python 3.8 或更高版本
  • 具有 API 访问权限的 GitLab 账户
  • Confluence 账户(可选,用于保存分析结果)
  • 对所需 GitLab 项目的访问权限

安装

  1. 克隆代码库:
git https://github.com/CodeByWaqas/MRConfluenceLinker-mcp-server.git
cd MRConfluenceLinker-mcp-server
  1. 创建并激活虚拟环境:
python -m venv .venv
source .venv/bin/activate  # On Windows, use: .venv\Scripts\activate
  1. 安装依赖:
pip install -r requirements.txt

或

uv add "mcp[cli]" python-gitlab python-dotenv atlassian-python-api requests

配置

  1. 复制环境变量示例文件:
cp .env.example .env
  1. 使用你的凭据编辑 .env 文件:
GITLAB_URL=https://gitlab.com
GITLAB_TOKEN=your_gitlab_token
GITLAB_PROJECT_ID=your_project_id

# Optional Confluence integration
CONFLUENCE_URL=your_confluence_url
CONFLUENCE_USERNAME=your_username
CONFLUENCE_TOKEN=your_confluence_token
CONFLUENCE_SPACE=your_space_key
获取凭据
  • GitLab Token:在 GitLab 中生成具有 api 范围的个人访问令牌
  • Confluence Token:在 Atlassian 账户设置中生成 API 令牌

使用方法

  1. 启动 MCP 服务:
python src/MRConfluenceLinker-mcp-server/server.py

或

使用 Claude Desktop 进行设置
# claude_desktop_config.json
# Can find location through:
# Claude -> Settings -> Developer -> Edit Config
{
  "mcpServers": {
      "MRConfluenceLinker-mcp-server": {
          "command": "uv",
          "args": [
              "--directory",
              "/<Absolute-path-to-folder>/MRConfluenceLinker-mcp-server/src/MRConfluenceLinker-mcp-server",
              "run",
              "server.py"
          ]
      }
  }
}

2. The server will listen for commands through stdin/stdout. You can interact with it using prompts like:

你能获取项目 "my-project" 中合并请求 #1 的详情吗? 你能分析项目 "my-project" 中合并请求 #1 的代码变更吗? 你能将项目 "my-project" 中合并请求 #1 的摘要保存到 Confluence 吗?


## Available Tools

The server provides the following tools:

1. `fetch_mr_details`: Fetches details of a specific merge request or all merge requests
   - Parameters:
     - `project_id`: The GitLab project ID
     - `mr_id` (optional): Specific merge request ID

2. `analyze_code_changes`: Analyzes code changes in a merge request
   - Parameters:
     - `project_id`: The GitLab project ID
     - `mr_id`: The merge request ID to analyze

3. `store_in_confluence`: Stores analysis results in Confluence
   - Parameters:
     - `project_id`: The GitLab project ID
     - `mr_id` (optional): Specific merge request ID
     - `analysis` (optional): Analysis results to store

## Logging

The server generates detailed logs in `mcp_server.log` and outputs to stderr. This helps in debugging issues with:
- GitLab API access
- Confluence integration
- Code analysis
- Page creation and updates

## Error Handling

The server includes comprehensive error handling for:
- Missing environment variables
- API authentication issues
- Network connectivity problems
- Invalid project or merge request IDs
- Confluence permission issues

## Contributing

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Support

For support, please [create an issue](https://github.com/CodeByWaqas/MRConfluenceLinker-mcp-server/issues) or contact the maintainers.

## Project Structure

MRConfluenceLinker-mcp-server/ ├── src/ # 源代码目录 │ └── MRConfluenceLinker-mcp-server/ # 主服务包 │ ├── resources/ # 资源模块 │ │ ├── init.py │ │ ├── client.py # 客户端实现 / GitLab PR 集成 │ ├── server.py # 主服务实现 │ └── mcp_server.log # 服务日志 ├── pycache/ # Python 缓存文件 ├── .git/ # Git 代码库 ├── .gitignore # Git 忽略规则 ├── CONTRIBUTING.md # 贡献指南 ├── LICENSE # 项目许可证 ├── README.md # 项目文档 ├── pyproject.toml # Python 项目配置 ├── requirements.txt # 项目依赖 └── uv.lock # 依赖锁定文件


### Key Components

- **Source Code**: Located in the `src/MRConfluenceLinker-mcp-server/` directory
  - `server.py`: Main MCP server implementation
  - `resources/client.py`: Client-side implementation contains GitLab PR integration

- **Configuration Files**:
  - `requirements.txt`: Python package dependencies
  - `pyproject.toml`: Project metadata and build configuration
  - `uv.lock`: Locked dependency versions
  - `.env.example`: Environment variables template

- **Documentation**:
  - `README.md`: Project overview and setup instructions
  - `CONTRIBUTING.md`: Contribution guidelines
  - `LICENSE`: Project license

- **Development**:
  - `__pycache__/`: Python cache files
  - `mcp_server.log`: Server logs for debugging

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。