Skip to main content

MCP server for CERN GitLab - code discovery, documentation access, and usage examples for HEP projects

Project description

CERN GitLab MCP Server

CERN GitLab MCP Server

An MCP server that connects LLMs to CERN GitLab for discovering HEP code, documentation, and analysis examples.

Features

  • 14 MCP tools for searching, browsing, and analyzing CERN GitLab repositories
  • Dual-mode operation — stdio (single-user) and HTTP (multi-user) modes
  • CLI tool (cerngitlab-cli) for direct command-line usage
  • Public access — works without authentication for public repositories
  • Multi-user support — HTTP mode enables centralized deployment for multiple users
  • HEP-focused — dependency parsing for Python and C++ ecosystems, binary detection for .root files, issue search
  • Robust — rate limiting, retries with exponential backoff, graceful error handling

Installation

Requires Python 3.10+.

Quickstart (recommended)

No installation needed — just use uvx to run directly:

uvx cerngitlab-mcp

From PyPI

pip install cerngitlab-mcp

From source

git clone https://github.com/MohamedElashri/cerngitlab-mcp
cd cerngitlab-mcp
uv sync

Configuration

All settings are configured via environment variables prefixed with CERNGITLAB_:

Variable Default Description
CERNGITLAB_GITLAB_URL https://gitlab.cern.ch GitLab instance URL
CERNGITLAB_TOKEN (empty) Personal access token (optional)
CERNGITLAB_TIMEOUT 30 HTTP timeout in seconds
CERNGITLAB_MAX_RETRIES 3 Max retries for failed requests
CERNGITLAB_RATE_LIMIT_PER_MINUTE 300 API rate limit
CERNGITLAB_LOG_LEVEL INFO Logging level
CERNGITLAB_DEFAULT_REF (empty) Default Git branch or tag to search within (e.g., main, master, v1.2.0). Empty means search all branches.
CERNGITLAB_HTTP_MODE (empty) Set to enable HTTP mode for multi-user deployment
CERNGITLAB_HOST localhost HTTP mode: host to bind to
CERNGITLAB_PORT 8000 HTTP mode: port to bind to

Authentication

The server works in two modes:

  • Without token — Access to all public repositories. Sufficient for most HEP code discovery.
  • With token — Additional access to internal/private projects, code search, and wiki pages.

To create a token:

  1. Go to https://gitlab.cern.ch/-/user_settings/personal_access_tokens
  2. Create a token with read_api scope
  3. Set CERNGITLAB_TOKEN=glpat-xxxxxxxxxxxx

Note: The code search (search_code), issue search (search_issues), and wiki (get_wiki_pages) tools require authentication on CERN GitLab.

Usage

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "cerngitlab": {
      "command": "uvx",
      "args": ["cerngitlab-mcp"],
      "env": {
        "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
      }
    }
  }
}

Note for macOS users: If you see an error about uvx not being found, you may need to provide the absolute path. Claude Desktop does not support ~ or $HOME expansion.

  1. Run which uvx in your terminal to find the path (e.g., /Users/yourusername/.local/bin/uvx).
  2. Use that absolute path in the command field:
"command": "/Users/yourusername/.local/bin/uvx"

Claude Code

Project-specific (default) — installs in the current directory's configuration:

claude mcp add cerngitlab-mcp -- uvx cerngitlab-mcp

Global — installs for your user account (works in all projects):

claude mcp add --scope user cerngitlab-mcp -- uvx cerngitlab-mcp

To include authentication, add -e CERNGITLAB_TOKEN=glpat-xxxxxxxxxxxx before the --:

# Example: Global installation with token
claude mcp add --scope user -e CERNGITLAB_TOKEN=glpat-xxxxxxxxxxxx cerngitlab-mcp -- uvx cerngitlab-mcp

Manual Configuration — you can also manually edit your global config at ~/.claude.json (on Linux/macOS) or %APPDATA%\Claude\claude.json (on Windows):

{
  "mcpServers": {
    "cerngitlab": {
      "command": "uvx",
      "args": ["cerngitlab-mcp"],
      "env": {
        "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
      }
    }
  }
}

GitHub Copilot

Add to your VS Code settings.json:

{
  "mcp": {
    "servers": {
      "cerngitlab": {
        "command": "uvx",
        "args": ["cerngitlab-mcp"],
        "env": {
          "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
        }
      }
    }
  }
}

Or add a .vscode/mcp.json to your project:

{
  "servers": {
    "cerngitlab": {
      "command": "uvx",
      "args": ["cerngitlab-mcp"],
      "env": {
        "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
      }
    }
  }
}

Gemini CLI

Add to your ~/.gemini/settings.json:

{
  "mcpServers": {
    "cerngitlab": {
      "command": "uvx",
      "args": ["cerngitlab-mcp"],
      "env": {
        "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
      }
    }
  }
}

Direct usage

Stdio Mode (Single-User, Default)

# Run with uvx (no install needed)
uvx cerngitlab-mcp

# Or if installed from PyPI
cerngitlab-mcp

# Explicit stdio mode
cerngitlab-mcp --mode stdio

# Or from source
uv run cerngitlab-mcp

# With authentication
CERNGITLAB_TOKEN=glpat-xxx uvx cerngitlab-mcp

HTTP Mode (Multi-User)

# HTTP mode for multi-user deployment
cerngitlab-mcp --mode http --host 0.0.0.0 --port 8080

# Or use environment variables
CERNGITLAB_HTTP_MODE=true CERNGITLAB_HOST=0.0.0.0 CERNGITLAB_PORT=8080 cerngitlab-mcp

# Dedicated HTTP entry point
cerngitlab-mcp-http

Mode Selection

  • --mode stdio - Single-user mode using stdin/stdout (default)
  • --mode http - Multi-user mode using HTTP API
  • --mode auto - Auto-detect based on environment variables

The server automatically detects HTTP mode if CERNGITLAB_HTTP_MODE, CERNGITLAB_HOST, or CERNGITLAB_PORT environment variables are set.

Tools

Tool Description Auth required
search_projects Search for public CERN GitLab projects (repositories) by keyword, topic, or language No
get_project_info Get detailed project metadata (stars, description, languages, statistics) No
list_project_files List files and directories in a project's repository No
get_file_content Fetch the content of a specific file (includes binary detection) No
get_project_readme Get the README content for a project No
search_code Search for code within a specific project or globally Yes*
search_lhcb_stack Search for code within an LHCb software stack (e.g., 'sim11'), with automatic Git ref resolution Yes*
search_issues Search for issues in a project Yes
get_wiki_pages List wiki pages for a project Yes
inspect_project Analyze project structure, build system, dependencies, and CI/CD No
list_releases List releases for a project No
get_release Get details of a specific release No
list_tags List tags for a project No
test_connectivity Test connection to the GitLab instance No

For detailed parameter documentation, see docs/dev.md.

Example Prompts

Search for repositories

"Search CERN GitLab for Python repositories related to ROOT analysis and show me the most starred ones"

Understand a project

"Get the README and file structure of the lhcb/DaVinci project on CERN GitLab"

Find fitting examples

"Search for repositories on CERN GitLab that use RooFit and show me example fitting code"

View LHCb software stack code

"Search the LHCb sim11 stack for the initialization routines in the Boole project"

Analyze a project structure

"Inspect the lhcb/allen project to understand its build system, dependencies, and CI pipeline configuration"

Find usage context

"Search for issues related to 'segmentation fault' in the atlas/athena project to see if others have encountered this"

Track releases

"List the recent releases of lhcb/DaVinci and show me the release notes for the latest version"

Find framework configurations

"Search for Gaudi framework configuration files on CERN GitLab and show me examples"

Development

See docs/dev.md for development setup, project structure, testing, and release instructions.

Multi-User HTTP Deployment

For centralized deployments serving multiple users, use HTTP mode:

Setup

# Start HTTP server
cerngitlab-mcp --mode http --host 0.0.0.0 --port 8080

# Or with environment variables
CERNGITLAB_HTTP_MODE=true CERNGITLAB_HOST=0.0.0.0 CERNGITLAB_PORT=8080 cerngitlab-mcp

User Authentication

For demo purposes, users can be configured via environment variables:

# Set up demo users
export CERNGITLAB_DEMO_USER_alice=glpat-alice-token
export CERNGITLAB_DEMO_USER_bob=glpat-bob-token

Users authenticate with Authorization: Bearer demo-alice header.

API Endpoints

  • GET / - Server information
  • GET /health - Health check
  • GET /tools - List available tools (authenticated)
  • POST /tools/{tool_name} - Execute specific tool (authenticated)
  • POST /mcp - Generic MCP endpoint (authenticated)

Example Usage

# List available tools
curl -H "Authorization: Bearer demo-alice" http://localhost:8080/tools

# Execute a tool
curl -X POST -H "Authorization: Bearer demo-alice" \
     -H "Content-Type: application/json" \
     -d '{"arguments": {"query": "ROOT"}}' \
     http://localhost:8080/tools/search_projects

CLI Tool

A command-line interface is also available for direct usage without the MCP server:

# Install or use with uvx
uvx cerngitlab-cli

# Test connectivity
cerngitlab-cli test-connection

# Search for projects
cerngitlab-cli search-projects --query "ROOT analysis" --language python

# Get project info
cerngitlab-cli get-project-info --project lhcb/DaVinci

# Search code
cerngitlab-cli search-code --search-term "RooFit" --per-page 10

# Inspect project structure
cerngitlab-cli inspect-project --project lhcb/allen

All commands output JSON to stdout for easy piping and composition. See cerngitlab-cli --help for the full list of commands.

Skill File

A detailed skill file (SKILL.md) is available with:

  • Complete documentation of all 14 tools
  • Input/output specifications
  • Usage examples
  • Authentication requirements

This can be used by LLMs or agents to understand the available tools and how to use them.

License

AGPL-3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cerngitlab_mcp-0.1.7.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cerngitlab_mcp-0.1.7-py3-none-any.whl (58.3 kB view details)

Uploaded Python 3

File details

Details for the file cerngitlab_mcp-0.1.7.tar.gz.

File metadata

  • Download URL: cerngitlab_mcp-0.1.7.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cerngitlab_mcp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 f2100650b9ca0b5cba1d434d0f9ba2fa82e6dd3ea2496531acad115a2c714902
MD5 a6fd1a0d5c31a5e4773914bf7bc08dce
BLAKE2b-256 deaa4d5687c96c2f6081f00c0ec7536ae6fc8912cc4cf6583031ec2413b3e360

See more details on using hashes here.

Provenance

The following attestation bundles were made for cerngitlab_mcp-0.1.7.tar.gz:

Publisher: release.yml on MohamedElashri/cerngitlab-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cerngitlab_mcp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: cerngitlab_mcp-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 58.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cerngitlab_mcp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4178dbed5b0a7f2efd6c5c5cf46bf057f848d693995e5aa877c9ef41c07daf33
MD5 c99e898d26be92eb947609ad0c190e9b
BLAKE2b-256 a93e0064d2c55ed2e69c700df67e2d7b78f6d93daf0f74a9e107e864d41b93c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cerngitlab_mcp-0.1.7-py3-none-any.whl:

Publisher: release.yml on MohamedElashri/cerngitlab-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page