Skip to main content
Glama
katamaraju

gitlab-mr-reviewer

by katamaraju
README.md
# GitLab MR Reviewer

AI-powered code review for GitLab merge requests. Ships as an MCP (Model Context Protocol) server for use with Kiro IDE, plus a standalone CLI for CI/CD pipelines.

## Features

- **GitLab MR Analysis** - Fetches MR diffs, threads, and metadata via GitLab API
- **Inline Code Comments** - Posts review findings directly on changed lines with severity and category
- **Multi-Model Council** - Runs multiple LLMs (via AWS Bedrock) in parallel for consensus-based review
- **Thread Management** - Reply, resolve, reopen discussion threads; auto-resolve fixed issues
- **Noise Filtering** - Automatically skips lockfiles, generated code, build output
- **Paginated Analysis** - Handles large MRs without context overflow
- **Import Resolution** - Follows imports to gather context from related files
- **Repository Profiles** - Learns project architecture and conventions over time
- **CI/CD Integration** - Standalone CLI for automated reviews in pipelines
- **Customizable Standards** - Teams can add code-review-standards/ to their repos

## Quick Start

### 1. Install

```bash
npm install -g gitlab-mr-reviewer
```

### 2. Configure

Create a .env file or set environment variables:

```bash
GITLAB_URL=https://gitlab.com
GITLAB_PAT=glpat-xxxxxxxxxxxx
```

### 3. Use with Kiro IDE

Add to your MCP config (~/.kiro/settings/mcp.json):

```json
{
  "mcpServers": {
    "gitlab-mr-reviewer": {
      "command": "mr-review-mcp",
      "args": [],
      "env": {
        "GITLAB_URL": "https://gitlab.com",
        "GITLAB_PAT": "glpat-xxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}
```

### 4. Use via CLI (CI/CD)

```bash
mr-review-cli --mr-url "https://gitlab.com/group/project/-/merge_requests/42"
mr-review-cli --project "group/project" --mr 42
mr-review-cli --mr-url $CI_MERGE_REQUEST_URL --dry-run
mr-review-cli --mr-url $CI_MERGE_REQUEST_URL --council
```

## Multi-Model Council Review

Multiple AI models independently review the same MR in parallel, then findings are consolidated by consensus.

### Enable Council

```bash
COUNCIL_ENABLED=true
COUNCIL_MODELS=claude-sonnet-4,claude-haiku-4.5,nova-pro
AWS_REGION=us-east-1
```

## Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| GITLAB_URL | Yes | - | GitLab instance URL |
| GITLAB_PAT | Yes | - | GitLab PAT (api scope) |
| REVIEW_LABEL | No | ai-review | Label added to reviewed MRs |
| COUNCIL_ENABLED | No | false | Enable multi-model review |
| COUNCIL_MODELS | No | claude-sonnet-4,claude-haiku-4.5,nova-pro | Models to use |
| AWS_REGION | No | us-east-1 | AWS region for Bedrock |
| BEDROCK_MAX_TOKENS | No | 8192 | Max tokens per model |
| REVIEW_MODE | No | deep | deep (clone) or quick (diff only) |

## Architecture

```text
src/
  index.ts              - Library exports
  mcp-server.ts         - MCP server class (tool implementations)
  mcp-server-stdio.ts   - STDIO transport + tool definitions
  cli-review.ts         - CLI entrypoint for CI/CD
  cache/                - MR data caching
  config/               - Retry and runtime configuration
  core/                 - Multi-model council, verification, pipeline
  modules/              - GitLab operations, analysis, comments
  types/                - TypeScript type definitions
  utils/                - Helpers (validation, errors, parsing)
power/
  POWER.md              - Kiro Power manifest
  mcp.json              - MCP server configuration
  steering/             - Review guidance files
```

## Development

```bash
git clone https://github.com/katamarajub/gitlab-mr-reviewer.git
cd gitlab-mr-reviewer
npm install
npm run build
```

## License

MIT