Utilizes local git repository metadata to automatically detect project paths, branches, and commits for seamless integration with GitLab API queries.
Integrates with GitHub Copilot to allow the AI assistant to query GitLab pipeline details, job statuses, and project information directly within the development workflow.
Enables monitoring of GitLab pipeline and job statuses, featuring automatic project detection from git remotes and support for self-hosted GitLab instances.
Designed for use within IntelliJ IDEA via the GitHub Copilot plugin to provide developers with real-time GitLab project monitoring and CI/CD status updates.
Click on "Install 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., "@GitLab MCP ServerCheck the status of the current pipeline and its jobs"
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.
GitLab MCP Server
A production-ready Model Context Protocol (MCP) server for GitLab that integrates with GitHub Copilot in IntelliJ IDEA. Automatically detects your GitLab project from git remote, monitors pipeline and job statuses with intelligent polling, and provides reliable API integration with retry logic.
Status: ✅ Fully Verified (35 tests, 100% pass rate)
Quick Start
1. Install Dependencies
2. Configure Environment
How to get a GitLab token:
GitLab Settings → Personal Access Tokens
Create token with scopes:
api,read_api,read_repositoryCopy token value to
.env
3. Start the Server
Expected output:
4. Configure in IntelliJ IDEA
Install GitHub Copilot plugin (if not already installed)
Settings → Tools → GitHub Copilot → MCP Servers
Add MCP Server:
Type:
stdioCommand:
python -m src.serverEnvironment: Point to your
.envfile
Features
✅ Automatic Project Detection
No need to specify project path
Automatically detected from git remote origin
Works with SSH and HTTPS URLs
Supports nested GitLab groups
✅ Pipeline Status Monitoring
Real-time pipeline status
All job details and statuses
Automatic branch and commit detection
Human-readable formatted output
✅ Job Status with Smart Polling
Polls every 2 seconds for job completion
Configurable timeout (default 30 seconds)
Returns intermediate states
Polling metadata included in response
✅ Reliable API Integration
3 retries with exponential backoff (1s, 5s, 9s)
Handles transient network failures gracefully
Session-level project ID caching
Clear error messages for debugging
✅ Self-Hosted GitLab Support
Works with any self-hosted GitLab instance
No dependency on gitlab.com
Full API compatibility
Available Tools
check_pipeline_status
Get pipeline status for current project and branch
What it does:
Auto-detects: project, branch, commit from git repository
Returns: pipeline ID, status, jobs with individual statuses
Format: Human-readable text report
Includes: timing, web URLs, stage information
Example:
check_job_status
Check specific job status with automatic polling
What it does:
Auto-detects: project, pipeline from current branch/commit
Searches: by job name or numeric job ID
Polls: every 2 seconds until completion (max 30s)
Returns: job status, timing, logs URL, polling metadata
Metadata:
is_polling,polling_timeout,polling_duration_seconds
Example:
Project Structure
Running Tests
Quick Test Run
Test Coverage
Total Tests: 35 (100% pass rate ✅)
Modules Tested: All 4 core modules
gitlab_client.py: 9 tests (API client, retry logic, caching)git_utils.py: 11 tests (URL parsing, validation)mcp_tools.py: 10 tests (polling, formatting, logic)server.py: 5 tests (initialization, configuration)
Running Specific Tests
Configuration
Environment Variables
Create .env file with:
Retry Logic Configuration
The client automatically retries failed API calls:
Total attempts: 3 (initial + 2 retries)
Backoff delays: 1s, 5s, 9s
Applies to: All GitLab API calls
Job Polling Configuration
Configure polling behavior via code:
Architecture
Troubleshooting
Configuration Issues
"GITLAB_URL environment variable is not set"
Verify
.envfile exists:ls -la .envCheck
.envhas GITLAB_URL:grep GITLAB_URL .envEnsure
.envis in working directory when running server
"GITLAB_TOKEN environment variable is not set"
Add
GITLAB_TOKENto.envToken format:
glpat-xxx(GitLab Personal Access Token)Verify token has correct scopes:
api,read_api,read_repository
"GitLab authentication successful" but tools fail
Check GitLab instance is accessible:
curl -H "PRIVATE-TOKEN: $TOKEN" $GITLAB_URL/api/v4/userVerify token has correct scopes
Check firewall/network access to GitLab instance
Git Issues
"Not a git repository"
Ensure you're in a git repository:
git remote -vSupported remote formats:
git@gitlab.host:group/project.githttps://gitlab.host/group/project.githttps://gitlab.host/group/project(without .git)http://gitlab.host/group/project(HTTP, not HTTPS)
"Unable to parse git remote URL"
Check git remote format:
git remote -vBoth SSH and HTTPS must be in standard GitLab format
Nested groups supported:
company/team/project
Pipeline/Job Issues
"No pipeline found for branch"
Verify branch has been pushed:
git pushCheck pipeline triggers are configured in GitLab
Try with explicit commit SHA:
check_pipeline_status(dir, commit="abc123")
"Job not found: test"
Verify job name matches exactly (case-sensitive)
Check pipeline has jobs (may be empty)
List jobs:
check_pipeline_status(dir)to see all jobs
Job polling times out (30 seconds)
Job hasn't started within 2-minute window
Can re-run tool to check current status
Tool returns last known state even after timeout
Debug Mode
Enable verbose logging:
Check logs during tool invocation for detailed error messages.
Verification & Testing
Test Results
What's Tested
✅ GitLab API client with mocked responses
✅ Retry logic and exponential backoff
✅ Project ID caching mechanism
✅ Git URL parsing (SSH, HTTPS, nested groups)
✅ Job polling with timeout
✅ Response formatting
✅ Server initialization and configuration
✅ Error handling and validation
Testing Without Real GitLab Instance
All tests use mocked GitLab API (no real API calls needed):
Performance
Typical Response Times
First API call: 1-3 seconds (depends on network)
Subsequent calls: <500ms (cached project ID)
Job polling: 2-second intervals
Total test suite: ~13 seconds
Caching Strategy
Project ID: Cached per server session
Reset: Server restart clears cache
Benefit: Reduces API calls for repeated operations
Implementation Details
Retry Logic
URL Parsing Examples
Job Polling Behavior
Supported Git Repositories
✅ Self-hosted GitLab instances (any version) ✅ gitlab.com (public GitLab) ✅ Nested groups (company/team/project/...) ✅ SSH and HTTPS remotes
❌ Not supported: GitHub, Bitbucket, etc. (GitLab only)
What to Do Next
1. Local Testing
2. Test GitLab Connection
3. Start the Server
4. Use with Copilot
In IntelliJ IDEA with Copilot:
"Check the pipeline status"
"What's the status of the test job?"
"Show me the latest pipeline"
Contributing
To add tests or features:
Create test file in
tests/directoryUse mocking for GitLab API:
patch('src.gitlab_client.gitlab.Gitlab')Run tests:
python -m pytest tests/ -vEnsure all tests pass before committing
Dependencies
Runtime
fastmcp>=2.14.0- Model Context Protocol serverpython-gitlab>=4.0.0- GitLab API clientpython-dotenv>=1.0.0- Environment variable loadingGitPython>=3.1.0- Git operations
Development/Testing
pytest>=8.0.0- Testing frameworkrequests-mock>=1.11.0- HTTP mocking (optional)
Implementation Status
Feature | Status | Tests |
Pipeline status monitoring | ✅ Complete | 4 |
Job status lookup | ✅ Complete | 5 |
Job polling | ✅ Complete | 4 |
Git URL parsing | ✅ Complete | 8 |
Retry logic | ✅ Complete | 1 |
Error handling | ✅ Complete | 3 |
Server initialization | ✅ Complete | 5 |
Configuration validation | ✅ Complete | 5 |
Support
For issues or questions:
Enable debug logging: Set
DEBUG=truein.envCheck logs: Review server output during tool invocation
Verify setup: Follow troubleshooting section above
Review tests: Check
tests/for usage examplesCheck git remote:
git remote -vmust be valid GitLab URL
License
[Add your license here]
Last Verified: February 10, 2026
Test Suite: 35/35 passing ✅
Status: Production Ready 🚀