mcp-server-gitlab

tmustafiz/mcp-server-gitlab

3.2

If you are the rightful owner of mcp-server-gitlab and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCP GitLab Repository Analysis Server is a Model Context Protocol server designed for analyzing GitLab repositories, providing tools for LLM coding agents to interact with and analyze these repositories.

Tools
7
Resources
0
Prompts
0

MCP GitLab Repository Analysis Server

A Model Context Protocol (MCP) server for analyzing GitLab repositories. This server provides tools for LLM coding agents to interact with and analyze GitLab repositories.

Features

  • MCP-compliant: Implements the MCP spec using @modelcontextprotocol/sdk
  • GitLab Integration: Uses @gitlab/sdk for GitLab operations
  • Git Operations: Uses simple-git for repository operations
  • Modular Tools: All tools are organized in separate modules for extensibility
  • Transports: Supports both HTTP (Streamable HTTP) and STDIO
  • TypeScript: Fully typed, strict, and documented
  • .env Config: Uses dotenv for configuration
  • Docker Support: Easy deployment with Docker and docker-compose
  • Extensible: Easy to add custom tools and extend functionality

Installation

npm install mcp-server-gitlab

Docker Installation

# Clone the repository
git clone https://github.com/yourusername/mcp-server-gitlab.git
cd mcp-server-gitlab

# Build and run with Docker
docker-compose up -d

Configuration

Create a .env file in your project root:

# Server Configuration
PORT=8080

# GitLab Configuration
GITLAB_URL=https://gitlab.com
GITLAB_TOKEN=your_gitlab_token
GITLAB_PROJECT_ID=your_project_id

# Repository Configuration
REPO_BRANCH=main
REPO_PATH=.

# Analysis Configuration
MAX_FILE_SIZE=1048576              # 1MB default
EXCLUDED_PATHS=node_modules,dist,.git
INCLUDED_FILE_TYPES=ts,js,tsx,jsx,json,md

Usage

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { registerAllTools } from "mcp-server-gitlab/tools";

const server = new McpServer({
  name: "My MCP Server",
  version: "1.0.0"
});

registerAllTools(server);

Docker Usage

# Start the server
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the server
docker-compose down

Built-in Tools

Repository Analysis

  • search_files: Search for files in the repository matching the query
  • get_file_content: Get the content of a specific file
  • get_project_info: Get information about the GitLab project
  • get_merge_requests: Get merge requests for the project

Repository Management

  • create_hotfix: Create a new hotfix branch from the main branch
  • commit_changes: Commit and push changes to the specified branch
  • create_merge_request: Create a merge request for the specified branch

Development

# Clone the repository
git clone https://github.com/yourusername/mcp-server-gitlab.git
cd mcp-server-gitlab

# Install dependencies
npm install

# Build
npm run build

# Start the server
npm start

Development Scripts

  • npm run build - Build the TypeScript project
  • npm start - Run the built server
  • npm run dev - Run the server in development mode using tsx
  • npm run release:beta - Create and publish a beta release
  • npm run release:patch - Create and publish a patch release
  • npm run release:minor - Create and publish a minor release
  • npm run release:major - Create and publish a major release
  • npm run docker:build - Build the Docker image
  • npm run docker:run - Run the Docker container

Dependencies

  • @modelcontextprotocol/sdk: ^1.12.1
  • dotenv: ^16.4.5
  • simple-git: ^3.22.0
  • @gitlab/sdk: ^38.1.0
  • glob: ^10.3.10
  • chalk: ^5.3.0
  • express: ^4.18.2

License

MIT