
GitLab PR Analysis MCP Server
This project provides an MCP (Model Control Protocol) server that integrates GitLab merge request analysis with Confluence documentation. It allows you to fetch merge request details, analyze code changes, and store the results in Confluence pages.
Features
- Fetch merge request details from GitLab
- Analyze code changes in merge requests
- Generate detailed reports including:
- Basic merge request information
- Code change statistics
- File type analysis
- Detailed file changes
- Store analysis results in Confluence
- Comprehensive logging for debugging
Available Tools
The server provides the following tools:
-
fetch_mr_details: Fetches details of a specific merge request or all merge requests- Parameters:
project_id: The GitLab project IDmr_id(optional): Specific merge request ID
- Parameters:
-
analyze_code_changes: Analyzes code changes in a merge request- Parameters:
project_id: The GitLab project IDmr_id: The merge request ID to analyze
- Parameters:
-
store_in_confluence: Stores analysis results in Confluence- Parameters:
project_id: The GitLab project IDmr_id(optional): Specific merge request IDanalysis(optional): Analysis results to store
- Parameters:
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
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- 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 or contact the maintainers.
Project Structure
MRConfluenceLinker-mcp-server/
โโโ src/ # Source code directory
โ โโโ MRConfluenceLinker-mcp-server/ # Main server package
โ โโโ resources/ # Resource modules
โ โ โโโ __init__.py
โ โ โโโ client.py # Client implementation / GitLab PR integration
โ โโโ server.py # Main server implementation
โ โโโ mcp_server.log # Server logs
โโโ __pycache__/ # Python cache files
โโโ .git/ # Git repository
โโโ .gitignore # Git ignore rules
โโโ CONTRIBUTING.md # Contributing guidelines
โโโ LICENSE # Project license
โโโ README.md # Project documentation
โโโ pyproject.toml # Python project configuration
โโโ requirements.txt # Project dependencies
โโโ uv.lock # Dependency lock fileKey Components
-
Source Code: Located in the
src/MRConfluenceLinker-mcp-server/directoryserver.py: Main MCP server implementationresources/client.py: Client-side implementation contains GitLab PR integration
-
Configuration Files:
requirements.txt: Python package dependenciespyproject.toml: Project metadata and build configurationuv.lock: Locked dependency versions.env.example: Environment variables template
-
Documentation:
README.md: Project overview and setup instructionsCONTRIBUTING.md: Contribution guidelinesLICENSE: Project license
-
Development:
__pycache__/: Python cache filesmcp_server.log: Server logs for debugging
pip install -r requirements.txtPrerequisites
- Python 3.8 or higher
- GitLab account with API access
- Confluence account (optional, for storing analysis results)
- Access to the required GitLab project(s)
Installation
- Clone the repository:
git https://github.com/CodeByWaqas/MRConfluenceLinker-mcp-server.git
cd MRConfluenceLinker-mcp-server- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtor
uv add "mcp[cli]" python-gitlab python-dotenv atlassian-python-api requestsConfiguration
- Copy the example environment file:
cp .env.example .env- Edit the
.envfile with your credentials:
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_keyObtaining Credentials
- GitLab Token: Generate a personal access token in GitLab with
apiscope - Confluence Token: Generate an API token in your Atlassian account settings
Usage
- Start the MCP server:
python src/MRConfluenceLinker-mcp-server/server.pyor
Setup with 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:
Can you fetch details for merge request #1 from project "my-project"? Can you analyze code changes in merge request #1 from project "my-project"? Can you store a summary of merge request #1 from project "my-project" in Confluence?
No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.