GitLab MCP Server

GitLab MCP Server

Enables AI assistants to interact with GitLab projects by listing merge requests, issues, and pipelines via MCP tools.

Category
访问服务器

README

GitLab MCP Server

A Model Context Protocol (MCP) server that exposes GitLab project data as tools consumable by AI assistants (e.g., GitHub Copilot, Claude Desktop).

Tools

Tool Description Parameters
list_merge_requests List open merge requests in a GitLab project project (string)
list_issues List issues in a GitLab project project (string)
list_pipelines List recent pipelines in a GitLab project project (string)

The project parameter accepts a GitLab project ID (integer) or URL-encoded namespace/path (e.g., mygroup%2Fmyrepo).

Requirements

  • Python 3.8+

Runtime dependencies are listed in requirements.txt and are automatically installed into an isolated virtual environment when you run start_server.sh (see Usage).

To install them manually:

pip install -r requirements.txt

For running tests:

pip install -r requirements-test.txt

Configuration

The server reads configuration from two environment variables:

Variable Description Example
GITLAB_URL Base URL of the GitLab API (v4) https://gitlab.spectrumflow.net/api/v4
GITLAB_TOKEN GitLab Personal Access Token with api scope glpat-xxxxxxxxxxxxxxxxxxxx

Export them before starting the server:

export GITLAB_URL=https://gitlab.spectrumflow.net/api/v4
export GITLAB_TOKEN=your-personal-access-token

Usage

Start the server

./start_server.sh

On first run the script will:

  1. Create a .venv virtual environment inside the project directory
  2. Install the packages from requirements.txt into that venv
  3. Launch mcp_server.py using the venv's Python interpreter

Subsequent runs reuse the existing venv and re-run the pip install step (which is a no-op if dependencies are already satisfied), so startup stays fast.

Or run manually (bring your own environment):

python3 mcp_server.py

Protocol

The server implements the Model Context Protocol (MCP) over stdio using JSON-RPC 2.0, which is the standard expected by VS Code Copilot, Claude Desktop, and other MCP clients.

Handshake sequence (performed automatically by MCP clients):

  1. Client → initialize
  2. Server → initialize result (protocolVersion, capabilities, serverInfo)
  3. Client → notifications/initialized (notification — no response)
  4. Client → tools/list
  5. Server → tools list

Call a tool:

{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "list_merge_requests", "arguments": {"project": "123"}}}

Response:

{"jsonrpc": "2.0", "id": 3, "result": {"content": [{"type": "text", "text": "[{\"id\": 42, \"title\": \"Fix bug\"}]"}]}}

Error response (e.g. missing parameter):

{"jsonrpc": "2.0", "id": 3, "error": {"code": -32602, "message": "Missing required argument: 'project'"}}

GitLab API failures are returned as results with "isError": true rather than JSON-RPC errors, per the MCP specification.

VS Code / Copilot MCP Configuration

Add to your mcp.json:

{
  "servers": {
    "gitlab": {
      "type": "stdio",
      "command": "/path/to/gitlab-mcp-server/start_server.sh",
      "env": {
        "GITLAB_URL": "https://gitlab.spectrumflow.net/api/v4",
        "GITLAB_TOKEN": "your-personal-access-token"
      }
    }
  }
}

Testing

The test suite has 58 tests across three layers. No network calls are made — all GitLab HTTP interactions are mocked.

python -m pytest
Layer File What it tests
Unit tests/unit/test_tools.py Tool functions (list_merge_requests, list_issues, list_pipelines) and send_response in isolation with mocked requests.get
Integration (in-process) tests/integration/test_main_loop.py main() dispatch loop via injected sys.stdin — routing, error handling, resilience after failures
Integration (subprocess) tests/integration/test_subprocess.py Real process spawned via subprocess.Popen — env var validation, tool discovery over the wire, wire protocol error paths

Run a specific layer:

python -m pytest tests/unit/
python -m pytest tests/integration/

Project Structure

gitlab-mcp-server/
├── mcp_server.py          # MCP server implementation
├── start_server.sh        # Startup script (bootstraps venv automatically)
├── requirements.txt       # Runtime dependencies
├── requirements-test.txt  # Test-only dependencies
├── pytest.ini             # pytest configuration
├── README.md
├── .venv/                 # Auto-created virtual environment (git-ignored)
└── tests/
    ├── conftest.py        # Shared pytest fixtures and env var setup
    ├── unit/
    │   └── test_tools.py  # Unit tests for tool functions
    └── integration/
        ├── test_main_loop.py   # In-process integration tests for main()
        └── test_subprocess.py  # Subprocess integration tests

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选