GitLab MCP Server
# GitLab MCP Server
<div align="center">
A Model Context Protocol (MCP) server for GitLab integration, enabling AI assistants to interact with GitLab merge requests, files, and perform intelligent code reviews.
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://gitlab.com/)
[](https://modelcontextprotocol.io/)
[Documentation](./docs/README.md) β’ [User Guide (δΈζ)](./docs/user-guide.md) β’ [API Reference](./docs/api-reference.md)
</div>
## Features
- π **MCP Protocol** - Full compliance with the official MCP TypeScript SDK
- π‘ **stdio Transport** - Compatible with Cursor, Claude Desktop, and other MCP clients
- π οΈ **Complete MR Toolkit** - Get MR details, changes, file contents, and more
- π€ **AI Code Review** - Intelligent code analysis with inline comments
- π **Line-level Comments** - Push precise code review feedback to GitLab
- π **Change Analysis** - Deep diff analysis for comprehensive reviews
- π **Review Rules Engine** - Smart rules based on file types and paths
- π **Enterprise Ready** - Supports private GitLab instances with retry mechanisms
## Quick Start
### Prerequisites
- Node.js >= 18.0.0
- pnpm (recommended) or npm
- GitLab Personal Access Token
### Installation
```bash
# Clone the repository
git clone https://github.com/LynnCen/gitlab-mcp
cd gitlab-mcp
# Install dependencies
pnpm install
# Build the project
pnpm build
```
### Configuration
Set your GitLab credentials:
```bash
export GITLAB_HOST="https://gitlab.com"
export GITLAB_TOKEN="glpat-xxxxxxxxxxxxx"
```
### Cursor Integration
Add to your Cursor MCP settings:
```json
{
"mcpServers": {
"gitlab-mcp": {
"type": "stdio",
"command": "node",
"args": ["/path/to/gitlab-mcp/dist/src/index.js"],
"env": {
"GITLAB_HOST": "https://gitlab.com",
"GITLAB_TOKEN": "your-token"
}
}
}
}
```
## Available Tools
| Tool | Description |
|------|-------------|
| `get_merge_request` | Get merge request details |
| `get_merge_request_changes` | Get MR file changes with diffs |
| `list_merge_requests` | List project merge requests |
| `update_merge_request_description` | Update MR description |
| `get_file_content` | Get file content from repository |
| `analyze_mr_changes` | Analyze MR changes for code review |
| `push_code_review_comments` | Push review comments to GitLab |
| `get_file_code_review_rules` | Get code review rules for file types |
## Usage Examples
```text
# Get MR information
Get the details of MR #123 in project company/awesome-project
# Perform code review
Analyze all changes in MR #123 of project company/awesome-project
and perform a comprehensive code review, then push comments to GitLab
# Update MR description
Update the description of MR #123 with the changes summary
```
## GitLab Token Setup
1. Go to GitLab β **Settings** β **Access Tokens**
2. Create a new token with these scopes:
- `api` - Full API access
- `read_user` - Read user info
- `read_repository` - Read repository content
- `write_repository` - Write repository (for comments)
## Documentation
- **[Documentation Center](./docs/README.md)** - Complete documentation index
- **[User Guide (δΈζ)](./docs/user-guide.md)** - Detailed usage guide in Chinese
- **[API Reference](./docs/api-reference.md)** - Full API documentation
- **[Configuration Guide](./docs/configuration.md)** - Environment and setup guide
- **[Development Guide](./docs/development/README.md)** - For contributors
## Development
```bash
# Development mode
pnpm dev
# Build
pnpm build
# Run tests
pnpm test
# Start server
pnpm start
```
## Roadmap
- [x] AI-powered code review with inline comments
- [x] Multi-severity issue classification (critical/warning/suggestion)
- [x] Smart review rules engine
- [ ] Batch MR review support
- [ ] Detailed quality reports
- [ ] Performance optimizations with caching
- [ ] Project-level configuration files
## Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
1. Fork the project
2. Create your feature branch: `git checkout -b feature/amazing-feature`
3. Commit your changes: `git commit -m 'feat: add amazing feature'`
4. Push to the branch: `git push origin feature/amazing-feature`
5. Open a Pull Request
## License
This project is licensed under the [MIT License](LICENSE).
## Acknowledgements
- [Model Context Protocol](https://modelcontextprotocol.io/) - MCP protocol and SDK
- [@gitbeaker/rest](https://github.com/jdalrymple/gitbeaker) - GitLab API client
- [Zod](https://github.com/colinhacks/zod) - TypeScript schema validation
---
<div align="center">
**If this project helps you, please give it a β**
Made with β€οΈ by the GitLab MCP Team
</div>
TDQS
Scored across 8 tools
analyze_mr_changes and get_merge_request_changes overlap significantly β both deal with an MR's changed files/diff, and an agent must read carefully to know one lists changes while the other produces review-oriented analysis. get_file_code_review_rules vs analyze_mr_changes also border on related review-prep concerns, though descriptions do help separate them.
All names are snake_case verb_noun (get_*, list_*, update_*, push_*, analyze_*), following a single predictable convention. There are no stylistic deviations or mixed casing.
Eight tools is well-scoped for a focused MR code-review assistant. Each tool maps to a distinct step in the review workflow (list, fetch, analyze, get rules, push comments).
The surface covers the read-and-comment review loop but lacks any way to read existing discussions/comments on an MR (risking duplicate comments) and has no MR create/approve/state-change operations. For a review-focused server these are notable gaps, though the core flow is usable.