CERN GitLab MCP Server
An MCP server that connects LLMs to CERN GitLab for discovering, browsing, and analyzing HEP repositories, code, documentation, and analysis examples.
Test connectivity to the CERN GitLab instance and check authentication/connection health.
Search projects by keyword, topic, language, and sort criteria to discover HEP code and frameworks.
Get project metadata such as description, statistics, stars, and languages.
List branches and search/filter them to select a Git ref for further exploration.
Browse repositories by listing files/directories, including recursive and path-specific lookups.
Fetch file content with metadata, binary detection, and language hints.
Read project READMEs with automatic detection of standard README filenames.
Search code globally or within a specific project, by content or filename.
Search LHCb software stacks (e.g.,
sim11) with automatic Git ref resolution.Search issues to find discussions, known errors, and feature support.
Access wiki pages, either listing them or retrieving a specific page.
Inspect projects for structure, build systems, dependencies, and CI/CD configuration.
List releases and tags, and get detailed release info including notes, assets, and download links.
Public repositories work without authentication; code, issue, and wiki search require a token.
Facilitates analysis of C++ projects through dependency parsing and retrieval of build configuration files.
Provides tools to find and analyze CMakeLists.txt files to understand repository build structures.
Enables the discovery and analysis of scientific codebases by parsing dependency files within Fortran ecosystems.
Enables repository exploration through file tree browsing, tag management, and release tracking.
Provides comprehensive tools for searching repositories, browsing files, and analyzing CI/CD configurations and wiki pages on CERN GitLab instances.
Allows for the retrieval and analysis of Makefiles to understand project build configurations.
Supports analysis of Python projects by parsing requirements.txt, pyproject.toml, and setup.py files to identify dependencies.
Parses TOML-based configuration files, such as pyproject.toml, to extract project dependency and metadata information.
Enables structural analysis of YAML files, specifically targeting GitLab CI/CD configurations and Conda environment definitions.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CERN GitLab MCP Server search for ATLAS analysis repositories written in Python"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Features
15 MCP tools for searching, browsing, and analyzing CERN GitLab repositories
MCP 2026-07-28 via SDK v2, with legacy client negotiation, structured output, and explicit read-only annotations
Dual-mode operation — stdio (single-user) and HTTP (multi-user) modes
CLI tool (
cerngitlab-cli) for direct command-line usagePublic access — works without authentication for public repositories
Multi-user HTTP mode — CERN SSO + GitLab OAuth authentication for centralized deployments; GitLab enforces all access permissions natively
HEP-focused — dependency parsing for Python and C++ ecosystems, binary detection for
.rootfiles, issue searchRobust — rate limiting, retries with exponential backoff, graceful error handling
Related MCP server: CERN ROOT MCP Server
Installation
Requires Python 3.10+.
Quickstart (recommended)
No installation needed — just use uvx to run directly:
uvx cerngitlab-mcpFrom PyPI
pip install cerngitlab-mcpFrom source
git clone https://github.com/MohamedElashri/cerngitlab-mcp
cd cerngitlab-mcp
uv syncConfiguration
All settings are configured via environment variables prefixed with CERNGITLAB_:
Variable | Default | Description |
|
| GitLab instance URL |
| (empty) | Personal access token (optional, for stdio mode) |
|
| HTTP timeout in seconds |
|
| Max retries for failed requests |
|
| API rate limit |
|
| Logging level |
| (empty) | Default Git branch or tag for code search. Empty uses GitLab's default ref behavior. |
| (empty) | Set any value to auto-detect HTTP mode |
|
| HTTP server bind address |
|
| HTTP server bind port |
| (empty) | HTTP mode — CERN SSO OAuth client ID |
| (empty) | HTTP mode — GitLab OAuth application client ID |
| (empty) | HTTP mode — GitLab OAuth application client secret |
|
| HTTP mode — Public base URL (used for OAuth callback) |
|
| HTTP mode — Additional allowed browser origins, as a JSON array |
|
| HTTP mode — Directory for persisting OAuth session files |
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:
Go to https://gitlab.cern.ch/-/user_settings/personal_access_tokens
Create a token with
read_apiscopeSet
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
Connect an MCP client
Clients launch the local server themselves. Install uv, then register the stdio command:
# Codex
codex mcp add cerngitlab -- uvx cerngitlab-mcp --mode stdio
# Claude Code (project scope)
claude mcp add --transport stdio --scope project cerngitlab -- uvx cerngitlab-mcp --mode stdioUse /mcp to check the connection, then ask the agent to run test_connectivity
and search CERN GitLab for a public project. Public access needs no token.
For authenticated access, see Authentication and the
client-specific environment settings in the guide below.
See the MCP client integration guide for Claude Desktop, VS Code, Copilot CLI, Cursor, Zed, Antigravity, Qwen Code, Pi/OMP, OpenCode, Cline, Roo Code, Continue, Goose, development checkouts, and authenticated remote HTTP setup. Ready-to-edit configurations are in examples/clients.
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-mcpHTTP 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-httpMode 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 for public CERN GitLab projects (repositories) by keyword, topic, or language | No |
| Get detailed project metadata (stars, description, languages, statistics) | No |
| List or search project branches and their commit metadata | No |
| List files and directories in a project's repository | No |
| Fetch the content of a specific file (includes binary detection) | No |
| Get the README content for a project | No |
| Search for code within a specific project or globally | Yes* |
| Search for code within an LHCb software stack (e.g., 'sim11'), with automatic Git ref resolution | Yes* |
| Search for issues in a project | Yes |
| List wiki pages for a project | Yes |
| Analyze project structure, build system, dependencies, and CI/CD | No |
| List releases for a project | No |
| Get details of a specific release | No |
| List tags for a project | No |
| 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"
Explore a branch
"Find branches containing 'release' in lhcb/DaVinci, then search the selected branch for Scheduler configuration"
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
HTTP mode provides a centralized server for multiple users. It uses CERN SSO + GitLab OAuth for authentication, users authenticate with their existing CERN identity, and GitLab's own permission system enforces all access controls.
Prerequisites
CERN SSO client — Register a client at the CERN Authorization Service. Note the client ID.
GitLab OAuth application — Create one at
https://gitlab.cern.ch/-/profile/applications.Set the redirect URI to
https://gitlabmcp.cern.ch/oauth/callback(replace with actual URL)Enable the
read_api read_repository read_userscopesNote the application ID and secret.
Setup
export CERNGITLAB_CERN_CLIENT_ID=your-cern-sso-client-id
export CERNGITLAB_GITLAB_OAUTH_CLIENT_ID=your-gitlab-oauth-app-id
export CERNGITLAB_GITLAB_OAUTH_CLIENT_SECRET=your-gitlab-oauth-secret
export CERNGITLAB_SERVER_BASE_URL=https://gitlabmcp.cern.ch
export CERNGITLAB_SESSION_STORAGE_PATH=/var/lib/cerngitlab/sessions # optional
# Start the server
cerngitlab-mcp --mode http --host 0.0.0.0 --port 8000See examples/oauth_server.py in the repository for a self-contained reference script.
Authentication Flow
Client sends a request with
Authorization: Bearer <cern-sso-token>header.Server validates the CERN SSO token via CERN's JWKS endpoint.
If the user has no active GitLab OAuth session,
/mcpreturns HTTP 403 with anauthorization_urlfield./oauth/authorizereturns authorization details as JSON.The user visits that URL, authorizes the GitLab OAuth application, and is redirected back to
/oauth/callback.Subsequent requests are served using the stored GitLab OAuth token. Sessions expire after 2 hours.
/mcp is the Streamable HTTP endpoint for MCP clients. Missing or invalid CERN
tokens return HTTP 401 with a WWW-Authenticate resource metadata challenge.
CERN client registration and the separate GitLab authorization remain required;
the metadata endpoint does not make this a standalone OAuth authorization server.
Use one server worker: pending OAuth state and PKCE verifiers are held in memory
for ten minutes and consumed once. Set CERNGITLAB_SERVER_BASE_URL to the exact
external origin so Host/Origin validation accepts requests through your proxy.
API Endpoints
Method | Path | Auth | Description |
|
| — | Server information |
|
| — | Health check |
|
| CERN SSO | MCP Streamable HTTP endpoint |
|
| — | OAuth protected resource metadata |
|
| CERN SSO | Start or check the OAuth authorization flow |
|
| — | Receive the GitLab OAuth code (browser redirect) |
|
| CERN SSO | List available MCP tools |
|
| CERN SSO | Execute a specific tool |
|
| CERN SSO | Revoke the current user's OAuth session |
|
| — | List all active sessions (admin use) |
Example Usage
Assuming the server is running at https://gitlabmcp.cern.ch and the CERN_SSO_TOKEN environment variable is set to a valid CERN SSO token:
# Step 1 – check authorization status
curl -H "Authorization: Bearer $CERN_SSO_TOKEN" \
https://gitlabmcp.cern.ch/oauth/authorize
# If authorization_required is true, visit authorization_url and authorize.
# Step 2 – list available tools (once authorized)
curl -H "Authorization: Bearer $CERN_SSO_TOKEN" \
https://gitlabmcp.cern.ch/tools
# Step 3 – execute a tool
curl -X POST -H "Authorization: Bearer $CERN_SSO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"arguments": {"query": "ROOT"}}' \
https://gitlabmcp.cern.ch/tools/search_projects
# Revoke session
curl -X DELETE -H "Authorization: Bearer $CERN_SSO_TOKEN" \
https://gitlabmcp.cern.ch/sessionCLI 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/allenAll 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 15 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
This software is provided under the AGPL-3.0 license.
Available Tools
15 toolsget_file_contentARead-onlyIdempotent
Retrieve the content of a specific file from a CERN GitLab repository. Returns the file content along with metadata like size, encoding, and a language hint for syntax highlighting. Binary files are detected and reported without attempting to decode them. Use start_line/end_line for focused reads of large source files; lines are 1-based and inclusive.
Inputs: project (required), file_path (required), ref, end_line, +1 more. Returns: object
get_project_infoBRead-onlyIdempotent
Get detailed information about a specific CERN GitLab project (metadata, statistics, description). Accepts either a numeric project ID or a full project path (e.g. 'atlas/athena').
Inputs: project (required). Returns: object
get_project_readmeARead-onlyIdempotent
Get the README file content for a CERN GitLab project. Automatically detects standard README filenames (README.md, README.rst, etc.). Returns the raw content — useful for understanding what a project does.
Inputs: project (required), ref. Returns: object
get_releaseARead-onlyIdempotent
Get detailed information about a specific release from a CERN GitLab repository. Returns release notes, assets, commit info, and download links. Requires the tag name of the release.
Inputs: project (required), tag_name (required). Returns: object
get_wiki_pagesARead-onlyIdempotent
Access wiki pages from a CERN GitLab repository. Can list all wiki pages or retrieve the content of a specific page. Useful for accessing project documentation that lives in the wiki.
Inputs: project (required), page_slug. Returns: object
inspect_projectARead-onlyIdempotent
Analyze a CERN GitLab repository to understand its structure, build system, and dependencies. Combines functionality of dependency analysis, build config detection, and CI/CD inspection into a single tool. Returns a comprehensive summary of the project's technical stack.
Inputs: project (required), ref. Returns: object
list_branchesARead-onlyIdempotent
List or search branches in a CERN GitLab repository. Returns branch names and commit metadata so a branch can be selected and passed as the 'ref' argument to repository content and code-search tools.
Inputs: project (required), page, search, per_page. Returns: object
list_project_filesBRead-onlyIdempotent
List files and directories in a CERN GitLab project's repository. Supports recursive listing and path specific lookups.
Inputs: project (required), ref, path, per_page, +1 more. Returns: object
list_releasesARead-onlyIdempotent
List releases from a CERN GitLab repository. Returns release tags, dates, and descriptions. Useful for tracking software versions and finding changelogs.
Inputs: project (required), per_page. Returns: object
list_tagsARead-onlyIdempotent
List tags from a CERN GitLab repository. Returns tag names with their associated commit references. Useful for finding version history and release points.
Inputs: project (required), sort, search, per_page. Returns: object
search_codeARead-onlyIdempotent
Search for code snippets across CERN GitLab repositories. Can search globally across all public projects or within a specific project. Returns matching files with line-level context. Useful for finding usage examples of specific libraries, functions, or patterns.
Inputs: search_term (required), ref, page, scope, +2 more. Returns: object
search_issuesARead-onlyIdempotent
Search for issues and discussions in CERN GitLab projects. Useful for understanding how a library is used, finding solution to common errors, or checking if a feature is supported.
Inputs: search_term (required), state, project, per_page. Returns: object
search_lhcb_stackARead-onlyIdempotent
Search for code snippets within a specific LHCb software stack (e.g., 'sim11'). Automatically resolves the correct Git references for projects in that stack.
Inputs: stack (required), search_term (required), ref, page, +3 more. Returns: object
search_projectsARead-onlyIdempotent
Search for public CERN GitLab projects (which contain repositories, issues, wikis, etc.) by keywords, topics, or programming language. Useful for discovering HEP code, analysis frameworks, and physics tools.
Inputs: order, query, topic, sort_by, +2 more. Returns: result
test_connectivityARead-onlyIdempotent
Test connectivity to the CERN GitLab instance. Returns the GitLab version, authentication status, and connection health.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Most tools target clearly distinct resources or actions, and descriptions clarify scope. A few pairs overlap by design: get_project_readme vs get_file_content, search_code vs search_lhcb_stack, and list_tags vs list_releases, though these remain understandable.
All tool names use snake_case and follow a predictable verb_noun pattern such as list_project_files, get_project_info, search_code, and list_releases. The specialized search_lhcb_stack and inspect_project still fit the convention cleanly.
Fifteen tools is within a reasonable range for a focused GitLab exploration server. Each tool covers a distinct capability, with no obvious padding or redundant operations.
The read-only exploration surface is fairly broad, covering projects, files, code search, issues search, wiki, branches, releases, and tags. However, common GitLab lifecycle operations are missing, including merge requests, pipelines, commit history, and any create/update/delete tools, which limits agents on many typical GitLab tasks.
Maintenance
Related MCP Connectors
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
MCP server for building and testing AI agents with multi-model experimentation and insights.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAn MCP server that exposes Rucio distributed data management operations as tools for LLMs. Designed for ATLAS physicists working with grid data on analysis facilities, but usable with any Rucio instance.6Apache 2.0
- AlicenseAqualityCmaintenanceAn MCP server and CLI tool that allow LLMs to interact with CERN ROOT files.9125 PyPI4MIT
- AlicenseAqualityBmaintenanceAn MCP server that integrates InspireHEP high-energy physics literature with LLMs. Search papers, explore citations, retrieve author metrics, and generate formatted references.9247 PyPI8AGPL 3.0
- AlicenseNot gradedqualityBmaintenanceMCP server for ATLAS Open Data that enables LLMs to discover, query, and retrieve public datasets and metadata from the ATLAS experiment at CERN.121 PyPI3Apache 2.0