GitLab MCP Server
Enables interaction with GitLab repositories through secure OAuth 2.0 authentication. Supports comprehensive GitLab operations including merge requests, issues, file management, commits, and branch operations through natural language.
README
GitLab MCP Server
@anupsahu/gitlab-mcp
Production-ready MCP (Model Context Protocol) server for GitLab API with OAuth 2.0 PKCE authentication.
Features
- 🔐 OAuth 2.0 PKCE Authentication - Secure authentication with token persistence
- 🔄 Automatic Token Refresh - Seamless token renewal with retry logic
- 📁 Complete GitLab API Coverage - Merge requests, issues, files, commits, and more
- 💾 Token Persistence - Sessions survive server restarts
- 🛡️ Production Ready - Clean codebase with comprehensive error handling
- 🔧 Easy Configuration - Simple setup with environment variables
Installation
npm install -g @anupsahu/gitlab-mcp
Quick Start
1. OAuth Authentication (Recommended)
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@anupsahu/gitlab-mcp"],
"env": {
"USE_OAUTH": "true",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
2. Personal Access Token (Alternative)
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@anupsahu/gitlab-mcp"],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
OAuth Authentication
The server supports OAuth 2.0 PKCE authentication for secure access to GitLab:
- Start the server with
USE_OAUTH=true - Authenticate using the
oauth_login_pkcetool - Tokens are automatically saved and persist across restarts
- Automatic token refresh handles expiration seamlessly
OAuth Tools
oauth_login_pkce- Initiate OAuth authenticationoauth_status- Check authentication statusoauth_logout- Logout and clear tokens
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
USE_OAUTH |
Enable OAuth 2.0 authentication | false |
GITLAB_API_URL |
GitLab API URL | https://gitlab.com/api/v4 |
GITLAB_PERSONAL_ACCESS_TOKEN |
Personal access token (if not using OAuth) | - |
GITLAB_PROJECT_ID |
Default project ID | - |
GITLAB_ALLOWED_PROJECT_IDS |
Comma-separated list of allowed project IDs | - |
GITLAB_READ_ONLY_MODE |
Enable read-only mode | false |
Available Tools
Repository Operations
search_repositories- Search for repositoriesget_repository_tree- Get repository file treeget_file_contents- Read file contentscreate_or_update_file- Create or update filespush_files- Push multiple files
Merge Request Operations
get_merge_request- Get merge request detailsget_merge_request_diffs- Get merge request changescreate_merge_request- Create new merge requestupdate_merge_request- Update merge requestmerge_merge_request- Merge a merge request
Issue Operations
create_issue- Create new issueget_issue- Get issue detailsupdate_issue- Update issuelist_issues- List issues
Commit Operations
list_commits- List repository commitsget_commit- Get commit detailsget_commit_diff- Get commit changes
Branch Operations
create_branch- Create new branchfork_repository- Fork repository
Token Storage
OAuth tokens are automatically saved to:
- Path:
~/.config/gitlab-mcp/oauth-config.json - Format: JSON configuration file
- Persistence: Tokens survive server restarts
- Security: Automatic token refresh and expiration handling
Examples
Authenticate with OAuth
// Use the oauth_login_pkce tool
{
"sessionId": "my-session" // optional
}
Get Merge Request Details
{
"project_id": "12345",
"merge_request_iid": "123",
"sessionId": "my-session"
}
Create Issue
{
"project_id": "12345",
"title": "Bug Report",
"description": "Description of the issue",
"sessionId": "my-session"
}
Development
# Clone repository
git clone https://gitlab.com/anupsahu/gitlab-mcp.git
cd gitlab-mcp
# Install dependencies
npm install
# Build
npm run build
# Run with OAuth
USE_OAUTH=true GITLAB_API_URL=https://gitlab.com/api/v4 node build/index.js
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a merge request
Support
For issues and questions:
- Create an issue in the GitLab repository
- Check existing documentation and examples
Built with ❤️ for the MCP ecosystem
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。