GitLab MCP Server
Integrates AI assistants with GitLab API to manage projects, issues, merge requests, files, and more through MCP tools and resources.
README
GitLab MCP Server
MCP (Model Context Protocol) server để tích hợp với GitLab API, cho phép AI assistants tương tác với GitLab thông qua các tools và resources.
Tính năng
Tools (Các thao tác có thể thực hiện)
Project Tools
list_projects- Liệt kê GitLab projectsget_project- Lấy thông tin chi tiết projectcreate_project- Tạo project mớisearch_projects- Tìm kiếm projects
Issue Tools
list_issues- Liệt kê issuesget_issue- Lấy thông tin chi tiết issuecreate_issue- Tạo issue mớiupdate_issue- Cập nhật issueclose_issue- Đóng issue
Merge Request Tools
list_merge_requests- Liệt kê merge requestsget_merge_request- Lấy thông tin chi tiết merge requestcreate_merge_request- Tạo merge request mớiupdate_merge_request- Cập nhật merge requestmerge_merge_request- Merge merge request
File Tools
get_file- Đọc file từ repositorylist_files- Liệt kê files trong directorycreate_file- Tạo file mớiupdate_file- Cập nhật file
Resources (Dữ liệu có thể truy cập)
gitlab://projects- Danh sách projectsgitlab://issues- Danh sách issuesgitlab://merge-requests- Danh sách merge requestsgitlab://project/{projectId}- Thông tin project cụ thểgitlab://issue/{projectId}/{issueIid}- Thông tin issue cụ thểgitlab://merge-request/{projectId}/{mrIid}- Thông tin merge request cụ thểgitlab://file/{projectId}/{filePath}- Nội dung file
Cài đặt
Yêu cầu
- Node.js >= 18.0.0
- GitLab Personal Access Token với các quyền:
api,read_api,write_repository
Cài đặt dependencies
npm install
Cài đặt global (tùy chọn)
Để cài đặt package này như một global command, bạn có thể sử dụng:
npm run install-global
Hoặc cài đặt trực tiếp từ thư mục hiện tại:
npm run build
npm install -g .
Sau khi cài đặt global, bạn có thể chạy server từ bất kỳ đâu bằng lệnh:
gitlab-mcp-server
Sử dụng với npx (không cần cài đặt)
Bạn cũng có thể chạy trực tiếp bằng npx mà không cần cài đặt global:
npx -y gitlab-mcp-server
Lưu ý: Nếu package chưa được publish lên npm, bạn có thể sử dụng npx với đường dẫn local:
npx -y /path/to/mcp_ts
Cấu hình
- Copy file
env.examplethành.env:
cp env.example .env
- Chỉnh sửa file
.envvà thêm GitLab token của bạn:
GITLAB_TOKEN=your_gitlab_personal_access_token_here
GITLAB_URL=https://gitlab.com/api/v4
Đối với GitLab self-hosted, thay đổi GITLAB_URL thành URL của instance của bạn.
Sử dụng
Build project
npm run build
Chạy server
npm start
Hoặc chạy ở chế độ development với auto-reload:
npm run dev
Type checking
npm run type-check
Cấu hình MCP Client
Claude Desktop
Thêm cấu hình sau vào file MCP settings của Claude Desktop (thường ở ~/Library/Application Support/Claude/claude_desktop_config.json trên macOS hoặc %APPDATA%\Claude\claude_desktop_config.json trên Windows):
Tùy chọn 1: Sử dụng npx (khuyến nghị, không cần cài đặt global):
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "gitlab-mcp-server"],
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Tùy chọn 2: Nếu đã cài đặt global:
{
"mcpServers": {
"gitlab": {
"command": "gitlab-mcp-server",
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Tùy chọn 3: Sử dụng đường dẫn local:
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": ["/path/to/mcp_ts/dist/index.js"],
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Cursor IDE
Thêm cấu hình vào file MCP settings của Cursor:
Tùy chọn 1: Sử dụng npx (khuyến nghị, không cần cài đặt global):
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "gitlab-mcp-server"],
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Tùy chọn 2: Nếu đã cài đặt global:
{
"mcpServers": {
"gitlab": {
"command": "gitlab-mcp-server",
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Tùy chọn 3: Sử dụng đường dẫn local:
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": ["/path/to/mcp_ts/dist/index.js"],
"env": {
"GITLAB_TOKEN": "your_gitlab_token_here",
"GITLAB_URL": "https://gitlab.com/api/v4"
}
}
}
}
Ví dụ sử dụng
Liệt kê projects
{
"tool": "list_projects",
"arguments": {
"search": "my-project",
"owned": true
}
}
Tạo issue
{
"tool": "create_issue",
"arguments": {
"projectId": "123",
"title": "Bug fix needed",
"description": "This is a bug that needs to be fixed",
"labels": "bug,urgent"
}
}
Đọc file từ repository
{
"tool": "get_file",
"arguments": {
"projectId": "group/project",
"filePath": "src/index.ts",
"ref": "main"
}
}
Cấu trúc dự án
mcp_ts/
├── src/
│ ├── index.ts # Entry point, MCP server setup
│ ├── config.ts # Configuration management
│ ├── gitlab/
│ │ ├── client.ts # GitLab API client wrapper
│ │ ├── projects.ts # Project operations
│ │ ├── issues.ts # Issue operations
│ │ ├── mergeRequests.ts # MR operations
│ │ └── files.ts # File operations
│ └── tools/
│ ├── projectTools.ts # MCP tools for projects
│ ├── issueTools.ts # MCP tools for issues
│ ├── mrTools.ts # MCP tools for merge requests
│ └── fileTools.ts # MCP tools for files
├── package.json
├── tsconfig.json
├── env.example
└── README.md
Phát triển
Thêm tool mới
- Tạo function trong module tương ứng trong
src/gitlab/ - Thêm tool definition vào file tương ứng trong
src/tools/ - Thêm handler trong function
handle*Tooltương ứng - Tool sẽ tự động được đăng ký trong MCP server
Error Handling
Tất cả các GitLab API calls đều được wrap với error handling. Errors sẽ được chuyển đổi thành messages dễ hiểu và trả về cho client.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。