GitLab PR Analysis MCP Server

MIT License
  • Linux
  • Apple

Integrations

  • Manages environment variables for the MCP server configuration, providing secure storage for GitLab and Confluence credentials.

  • Stores GitLab merge request analysis results in Confluence pages, allowing teams to document and share code change reports within their Confluence workspace.

  • Fetches merge request details and analyzes code changes from GitLab projects, providing statistics, file type analysis, and detailed file changes.

GitLab PR 分析 MCP 服务器

该项目提供了一个 MCP(模型控制协议)服务器,它将 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/ # 主服务器包 │ ...

### 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
-
security - not tested
A
license - permissive license
-
quality - not tested

将 GitLab 合并请求分析与 Confluence 文档集成,允许用户获取合并请求详细信息、分析代码更改并将分析结果存储在 Confluence 页面中。

  1. Features
    1. Prerequisites
      1. Installation
        1. Configuration
          1. Obtaining Credentials
        2. Usage
          1. Setup with Claude Desktop
        ID: 0udc9poo5j