Get the FREE Ultimate OpenClaw Setup Guide →

gitlab-api

GitLab MCP Server and Python API Wrapper

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio knuckles-team-gitlab-api uvx gitlab-api \
  --env GITLAB_TOKEN="<your-personal-access-token>" \
  --env GITLAB_BASE_URL="https://gitlab.example.com/api/v4"

How to use

This MCP server wraps the GitLab REST API and exposes it as a collection of MCP Tools that can be orchestrated by an MCP-capable LLM. It enables an Agent-to-Agent (A2A) workflow where a coordinating orchestrator delegates subtasks to specialized child agents (e.g., branches, commits, merge requests). The included MCP Tools correspond to common GitLab API endpoints such as branches, commits, merge requests, pipelines, projects, and users, each designed to be called with structured parameters and integrated into a shared knowledge graph for reasoning. To use it, run the server with the provided uvx target and authenticate with a GitLab access token via environment variables. Once running, you can call the tools through your MCP-enabled client or agent framework, enabling tasks like listing branches, creating a branch, or retrieving merge request details via the modular toolset.

Typical capabilities include: getting branches (get_branches), creating commits (create_commit), managing merge requests (get_merge_requests, create_merge_request), querying pipelines (get_pipelines), and interacting with project metadata (get_projects, get_project). Each tool maps to a specific API resource and exposes a concise interface for LLM-driven orchestration, while the underlying orchestration ensures sub-tasks are delegated to the appropriate specialized tools and the results are combined in a coherent response.

How to install

Prerequisites:

  • Python 3.8+ installed on the host
  • Access to install Python packages (pip)
  • A GitLab instance accessible from your environment

Install instructions:

  1. Ensure Python is available and updated
    • macOS: brew install python
    • Linux: sudo apt-get update && sudo apt-get install python3 python3-pip
  2. Create and activate a virtual environment (optional but recommended)
    • python3 -m venv venv
    • source venv/bin/activate # macOS/Linux
    • venv\Scripts\activate # Windows
  3. Install the package from PyPI (gitlab-api) or your preferred source
    • pip install gitlab-api
  4. Prepare environment variables for authentication and configuration
  5. Run the MCP server (via uvx as described in mcp_config)
    • Ensure the uvx command is available and the package is installed
    • Follow the mcp_config setup to start the server with the proper environment

Notes:

  • If you need to customize endpoints or add a proxy, adjust GITLAB_BASE_URL accordingly.
  • The server expects a valid GitLab personal access token with appropriate scopes for the APIs you intend to use.

Additional notes

Environment variables you may use:

  • GITLAB_BASE_URL: Base API URL for GitLab (default: https://gitlab.com/api/v4)
  • GITLAB_TOKEN: Personal access token with required scopes (e.g., api, read_api)
  • Optional: EUNOMIA_ENABLED to enable policy-based access control if configured Common issues:
  • Token or base URL misconfiguration leading to 401/403 responses
  • Network access restrictions to GitLab instance
  • Ensure the MCP client and orchestrator are aligned in terms of tool names and parameters (case-sensitive) Configuration tips:
  • Keep tokens secure; do not hardcode tokens in code or logs
  • Use environment-specific URLs during development vs. production

Related MCP Servers

Sponsor this space

Reach thousands of developers