npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@danielsuri/gitlab-mcp-server

v0.1.7

Published

A Model Context Protocol (MCP) server for fetching GitLab merge request diffs from private GitLab instances

Downloads

36

Readme

Private GitLab MCP Server

A Model Context Protocol (MCP) server for fetching GitLab merge request diffs from your private GitLab instance.

Installation

👉 [Copy and paste it in your browser]

vscode:mcp/install?%7B%22name%22%3A%22privateGitLabMCP%22%2C%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22%40danielsuri%2Fgitlab-mcp-server%22%5D%2C%22env%22%3A%7B%22GITLAB_URL%22%3A%22%24%7Binput%3Agitlab-url%7D%22%2C%22GITLAB_TOKEN%22%3A%22%24%7Binput%3Agitlab-token%7D%22%2C%22GITLAB_PROJECT_PATH%22%3A%22%24%7Binput%3Agitlab-project-path%7D%22%7D%7D

NPM Package (Recommended)

Install the package using npm:

npm install -g gitlab-mcp-server

The npm package provides:

  • Easy installation: Single npm command
  • Cross-platform: Works on Node.js 14+
  • Automatic updates: Use npm update to get latest version
  • Global CLI: Use gitlab-mcp-server command anywhere

From Source (Development)

For development or if you prefer to build from source:

1. Install Dependencies

First, clone the repository and install the required packages:

git clone https://github.com/Danielsuri/gitlab-mcp-server.git
cd gitlab-mcp-server
npm install

Usage

Using the NPM Package

After installing the npm package globally, you can use the server directly:

# Run the server
gitlab-mcp-server

# Or use it programmatically
node -e "require('gitlab-mcp-server').main()"

2. Configure GitLab Access

You need to set up your GitLab personal access token and URL:

  1. Get your GitLab Personal Access Token:

    • Go to your GitLab instance (e.g., https://gitlab.example.com)
    • Navigate to User Settings → Access Tokens
    • Create a new token with read_api scope
    • Copy the generated token
  2. Update the configuration:

    • Open mcp.json
    • Replace YOUR_GITLAB_TOKEN_HERE with your actual GitLab token
    • Update the GITLAB_URL if you're using a different GitLab instance (default is https://gitlab.example.com)

3. Configure MCP Client

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

Copy the contents of mcp.json to your MCP client configuration file.

For Claude Desktop:

  • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%/Claude/claude_desktop_config.json

Make sure to update the cwd path in the configuration to match your actual project directory.

Manual VS Code Installation

If you want to run the server manually in VS Code:

  1. Create a .vscode directory in your project and add an mcp.json file inside it.
  2. In VS Code, click Add Server, choose npm package, and paste @danielsuri/[email protected].
  3. Your .vscode/mcp.json should look like:
{
    "servers": {
        "gitlab-mcp-server": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "@danielsuri/[email protected]"
            ],
            "cwd": "${workspaceFolder}",
            "env": {
                "GITLAB_URL": "https://gitlab.example.com",
                "GITLAB_TOKEN": "YOUR_GITLAB_TOKEN_HERE",
                "GITLAB_PROJECT_PATH": "your-group/your-project"
            }
        }
    },
    "inputs": []
}
  1. Replace the GITLAB_URL, GITLAB_TOKEN, and GITLAB_PROJECT_PATH values with your GitLab instance URL, personal access token, and project path.
  2. Start the server from the MCP extension.

Available Tools

hello_world

Returns a friendly hello message to test the connection.

fetch_merge_request_diff

Fetches the diff of a GitLab merge request.

Parameters:

  • project_path (string): The GitLab project path (e.g., "group/subgroup/project")
  • mr_iid (integer): The merge request IID (internal ID)

Example usage:

{
  "project_path": "your-group/your-project",
  "mr_iid": 9045
}

get_merge_request_commentable_lines

Gets a list of lines that can be commented on in a merge request diff. This is useful to identify valid line numbers before adding inline comments.

Parameters:

  • project_path (string): The GitLab project path (e.g., "group/subgroup/project")
  • mr_iid (integer): The merge request IID (internal ID)

Returns: A list of files with their commentable lines, including:

  • type: "new" for added lines, "old" for removed lines
  • line_number: The line number in the file
  • content: The actual line content

add_merge_request_inline_comment

Adds an inline comment to a specific line in a merge request diff. Only lines that have been changed (added or removed) can be commented on.

Parameters:

  • project_path (string): The GitLab project path
  • mr_iid (integer): The merge request IID
  • file_path (string): Path to the file in the diff
  • line_number (integer): Line number to comment on (use get_merge_request_commentable_lines to find valid lines)
  • comment_body (string): The comment text
  • line_type (string, optional): "new" for added lines or "old" for removed lines (default: "new")

Example usage:

{
  "project_path": "group/project",
  "mr_iid": 123,
  "file_path": "src/main.js",
  "line_number": 15,
  "comment_body": "This function could be optimized",
  "line_type": "new"
}

Testing

You can test the server manually:

# Test hello world
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "hello_world", "arguments": {}}}' | node server.js

# Test merge request diff fetch
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "fetch_merge_request_diff", "arguments": {"project_path": "your/project/path", "mr_iid": 123}}}' | node server.js

# Test getting commentable lines
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "get_merge_request_commentable_lines", "arguments": {"project_path": "your/project/path", "mr_iid": 123}}}' | node server.js

# Test adding an inline comment (requires valid GitLab credentials)
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "add_merge_request_inline_comment", "arguments": {"project_path": "your/project/path", "mr_iid": 123, "file_path": "src/main.js", "line_number": 15, "comment_body": "Test comment"}}}' | node server.js

Running Unit Tests

# Test basic functionality
npm test

# Test hello world specifically
npm run test-hello

From Source Testing

# Test hello world with test server
echo '{"type":"tools/call","name":"hello_world","params":{}}' | node test-server.js

Development

NPM Scripts

  • npm start - Run the main server
  • npm test - Run the test server
  • npm run test-hello - Test hello world function specifically

Environment Variables

  • GITLAB_URL - GitLab instance URL (default: "https://gitlab.example.com")
  • GITLAB_TOKEN - GitLab personal access token with read_api scope
  • GITLAB_PROJECT_PATH - GitLab project path (default: "your-group/your-project")

Creating Releases

This project uses automated release management. To create a new release:

  1. Go to GitHub Actions → "Create Release" workflow
  2. Click "Run workflow" and enter the new version (e.g., 1.0.0)
  3. The workflow will automatically update all version references and publish to NPM

See RELEASE.md for detailed release process documentation.

Requirements

  • Node.js 14.0.0 or higher
  • Valid GitLab personal access token with read_api scope
  • Network access to your GitLab instance

Dependencies

  • axios - HTTP client for GitLab API requests

Troubleshooting

  • Connection issues: Make sure you're connected to the VPN if your GitLab instance requires it
  • 401 Unauthorized: Check that your GitLab token is valid and has the correct permissions
  • 404 Project Not Found: Verify the project path is correct and you have access to the project