Skip to main content
Glama
nonamebkz

mcp-http-gitlab

by nonamebkz
README.md
# mcp-http-gitlab

MCP server for posting inline comments on GitLab merge request line changes via the REST API.

## Tools

| Tool | Description |
|------|-------------|
| `gitlab_get_merge_request` | MR metadata and `diff_refs` SHAs |
| `gitlab_get_mr_changes` | Changed files with raw diffs |
| `gitlab_create_mr_line_comment` | Post inline comment on a diff line |

## Setup

```bash
npm install
npm run build
```

## Environment

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `GITLAB_TOKEN` | yes | — | Personal access token with `api` scope |
| `GITLAB_URL` | no | `https://gitlab.com` | GitLab instance base URL |

## Cursor MCP config

Add to `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "gitlab": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-http-gitlab/dist/index.js"],
      "env": {
        "GITLAB_TOKEN": "glpat-your-token-here",
        "GITLAB_URL": "https://gitlab.com"
      }
    }
  }
}
```

## Typical agent flow

1. `gitlab_get_merge_request` — confirm MR state and get SHAs
2. `gitlab_get_mr_changes` — read diffs and pick a file/line
3. `gitlab_create_mr_line_comment` — post the review comment

### Example: create inline comment

```json
{
  "project_path": "my-group/my-repo",
  "mr_iid": 42,
  "file_path": "src/main.ts",
  "line_number": 15,
  "body": "Consider extracting this into a helper function."
}
```

## Agent integration

Skill, Cursor rules, and install snippets live in [`agent/`](agent/README.md):

```bash
./agent/scripts/install-cursor.sh   # symlink skill → ~/.cursor/skills/
```

Copy `agent/cursor-rules/*.mdc` into target repos under `.cursor/rules/`.
See [agent/README.md](agent/README.md) for full integration steps.

## Notes

- Token is read from the environment only (never passed as a tool argument).
- The server validates the token on startup via `GET /user`.
- Line numbers refer to lines visible in the MR diff (new-file lines for additions/context).
- Renamed files are resolved automatically from MR changes.
- MVP scope: new discussions only (no reply/resolve).