GitLab Review MCP

GitLab Review MCP

Enables code review operations on GitHub and GitLab, including fetching pull/merge requests, viewing diffs, adding comments, analyzing code quality, and creating merge requests directly from your MCP client.

Category
Visit Server

README

Node Code Review MCP

A Node.js implementation of the Model Context Protocol (MCP) server for code review operations, supporting both GitHub and GitLab platforms.

πŸ“– δΈ­ζ–‡ζ–‡ζ‘£: README-zh.md | εΏ«ι€ŸεΌ€ε§‹ | εŠŸθƒ½ε―Ήζ―”

Features

  • πŸ” Fetch pull request/merge request details
  • πŸ“„ Get code diffs for PRs or commits
  • πŸ’¬ Add review comments
  • πŸ” Basic code quality analysis
  • πŸ”§ Configurable via command line arguments
  • 🌐 Support for both GitHub and GitLab APIs

Installation

Via NPM (when published)

npm install -g gitlab-review-mcp

Local Development

git clone <repository>
cd gitlab-review-mcp
npm install
npm run build

Configuration

Environment Variables

Copy env.example to .env and configure:

# API Configuration
API_BASE_URL=https://api.github.com
API_TOKEN=your_github_token_here

# For GitLab, use:
# API_BASE_URL=https://gitlab.com/api/v4
# API_TOKEN=your_gitlab_token_here

# Server Configuration
TIMEOUT=30000
MAX_RETRIES=3

Command Line Arguments

gitlab-review-mcp \
  --api-base-url https://api.github.com \
  --api-token your_token \
  --timeout 30000 \
  --max-retries 3

MCP Configuration

Add to your MCP client configuration (e.g., Claude Desktop):

Using NPX (Recommended)

{
  "mcpServers": {
    "gitlab-review-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "gitlab-review-mcp",
        "--api-base-url=https://api.github.com",
        "--api-token=your_github_token_here"
      ],
      "alwaysAllow": [
        "fetch_pull_request",
        "fetch_code_diff",
        "add_review_comment",
        "analyze_code_quality",
        "get_server_config",
        "create_merge_request",
        "get_current_branch",
        "get_project_info"
      ]
    }
  }
}

Using Local Installation

{
  "mcpServers": {
    "gitlab-review-mcp": {
      "command": "node",
      "args": [
        "/path/to/gitlab-review-mcp/dist/index.js",
        "--api-base-url=https://api.github.com",
        "--api-token=your_github_token_here"
      ],
      "alwaysAllow": [
        "fetch_pull_request",
        "fetch_code_diff",
        "add_review_comment",
        "analyze_code_quality",
        "get_server_config",
        "create_merge_request",
        "get_current_branch",
        "get_project_info"
      ]
    }
  }
}

For GitLab

{
  "mcpServers": {
    "gitlab-review-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "gitlab-review-mcp",
        "--api-base-url=https://gitlab.com/api/v4",
        "--api-token=your_gitlab_token_here"
      ],
      "alwaysAllow": [
        "fetch_pull_request",
        "fetch_code_diff",
        "add_review_comment",
        "analyze_code_quality",
        "get_server_config",
        "create_merge_request",
        "get_current_branch",
        "get_project_info"
      ]
    }
  }
}

Available Tools

fetch_pull_request

Fetch pull request/merge request details.

Parameters:

  • repository (string): Repository in format "owner/repo" or GitLab project path like "group/project" (aliases: projectId, project_path)
  • pullRequestNumber (number): Pull request number
  • provider (string, optional): "github" or "gitlab" (default: "gitlab")

fetch_code_diff

Fetch code diff for a pull request or commit.

Parameters:

  • repository (string): Repository in format "owner/repo" or GitLab project path like "group/project"
  • pullRequestNumber (number, optional): Pull request number
  • commitSha (string, optional): Commit SHA
  • filePath (string, optional): Specific file path to get diff for
  • provider (string, optional): "github" or "gitlab" (default: "gitlab")

add_review_comment

Add a review comment to a pull request.

Parameters:

  • repository (string): Repository in format "owner/repo" or GitLab project path like "group/project"
  • pullRequestNumber (number): Pull request number
  • body (string): Comment body
  • filePath (string, optional): File path for line comment
  • line (number, optional): Line number for line comment
  • provider (string, optional): "github" or "gitlab" (default: "gitlab")

analyze_code_quality

Analyze code quality and provide suggestions with detailed metrics.

Parameters:

  • code (string): Code content to analyze
  • language (string): Programming language (javascript, typescript, python, java, go, etc.)
  • rules (array, optional): Specific rules to check

get_repository_info

Get repository information.

Parameters:

  • repository (string): Repository in format "owner/repo" or GitLab project path like "group/project"
  • provider (string, optional): "github" or "gitlab" (default: "gitlab")

analyze_files_batch

Analyze multiple files for code quality issues.

Parameters:

  • files (array): Array of file objects with path, content, and language properties
  • rules (array, optional): Specific rules to apply to all files

get_pull_request_files

Get list of files changed in a pull request.

Parameters:

  • repository (string): Repository in format "owner/repo" or GitLab project path like "group/project"
  • pullRequestNumber (number): Pull request number
  • provider (string, optional): "github" or "gitlab" (default: "gitlab")

get_supported_languages

Get list of supported programming languages for code analysis.

get_language_rules

Get available analysis rules for a specific language.

Parameters:

  • language (string): Programming language

get_server_config

Get current server configuration and health status.

create_merge_request πŸ†•

Create a new GitLab merge request from a source branch with enhanced error handling.

Parameters:

  • projectId (string): GitLab project ID or path
    • Numeric ID (recommended): "12345"
    • Project path: "group/project" or "group/subgroup/project"
  • sourceBranch (string): Source branch name (e.g., "feature/new-feature")
  • targetBranch (string, optional): Target branch name (defaults to "main")
  • title (string, optional): Merge request title (auto-generated from branch name if not provided)
  • description (string, optional): Merge request description
  • assigneeId (number, optional): User ID to assign the merge request to
  • reviewerIds (array, optional): Array of user IDs to request reviews from
  • deleteSourceBranch (boolean, optional): Whether to delete source branch when MR is merged
  • squash (boolean, optional): Whether to squash commits when merging

Enhanced Error Handling:

  • Project ID validation with detailed error messages
  • Automatic project verification before MR creation
  • Comprehensive troubleshooting guidance for common errors (404, 401, 403, etc.)
  • Support for both numeric IDs and project paths

Example:

// Minimal usage
{
  "projectId": "mygroup/myproject",
  "sourceBranch": "feature/user-authentication"
}

// Full configuration
{
  "projectId": "12345",
  "sourceBranch": "feature/user-authentication",
  "targetBranch": "develop",
  "title": "feat: Add user authentication system",
  "description": "This MR adds JWT-based authentication with password hashing.",
  "assigneeId": 123,
  "reviewerIds": [456, 789],
  "deleteSourceBranch": true,
  "squash": true
}

Auto-generated Titles: The tool automatically generates conventional commit-style titles based on branch prefixes:

  • feature/ β†’ feat:
  • bugfix/ β†’ fix:
  • hotfix/ β†’ fix:
  • docs/ β†’ docs:
  • refactor/ β†’ refactor:

get_current_branch πŸ†•

Get current Git branch and repository information.

Parameters:

  • workingDirectory (string, optional): Working directory path (defaults to current directory)

Example:

{
  "workingDirectory": "/path/to/your/project"
}

Returns:

{
  "currentBranch": "feature/user-authentication",
  "allBranches": ["main", "feature/user-authentication", "develop"],
  "isGitRepository": true,
  "repositoryRoot": "/path/to/your/project"
}

get_project_info πŸ†•

Get current GitLab project information from Git remotes.

Parameters:

  • workingDirectory (string, optional): Working directory path (defaults to current directory)
  • remoteName (string, optional): Git remote name (defaults to "origin")

Example:

{
  "workingDirectory": "/path/to/your/project",
  "remoteName": "origin"
}

Returns:

{
  "projectId": "group%2Fproject",
  "projectPath": "group/project",
  "gitlabUrl": "https://gitlab.com",
  "remotes": [
    {
      "name": "origin",
      "url": "git@gitlab.com:group/project.git",
      "fetch": "git@gitlab.com:group/project.git",
      "push": "git@gitlab.com:group/project.git"
    }
  ],
  "isGitlabProject": true
}

API Token Setup

GitHub

  1. Go to GitHub Settings > Developer settings > Personal access tokens
  2. Generate a new token with appropriate permissions:
    • repo scope for private repositories
    • public_repo scope for public repositories only

GitLab

  1. Go to GitLab User Settings > Access Tokens
  2. Create a personal access token with:
    • api scope for full API access
    • read_api scope for read-only access

Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build
npm run build

# Clean build directory
npm run clean

License

MIT License - see LICENSE file for details.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured