Troubleshooting Guide¶
This comprehensive troubleshooting guide helps resolve common issues with the MCP-GitLab integration.
Quick Reference¶
Issue Category | Quick Fix | Detailed Section |
---|---|---|
Connection Issues | Check network/credentials | Connection Problems |
Authentication Errors | Verify tokens/permissions | Authentication Issues |
Performance Problems | Check resource usage | Performance Issues |
API Errors | Validate request format | API Troubleshooting |
Connection Problems¶
GitLab Connection Failed¶
Symptoms: - Cannot connect to GitLab instance - Timeout errors - Connection refused messages
Diagnosis:
# Test GitLab connectivity
curl -I https://your-gitlab-instance.com
# Check DNS resolution
nslookup your-gitlab-instance.com
# Test API endpoint
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://your-gitlab-instance.com/api/v4/user
Solutions:
-
Network Issues
-
SSL/TLS Issues
-
Proxy Configuration
MCP Server Won't Start¶
Symptoms: - Server fails to start - Port binding errors - Module loading failures
Diagnosis:
# Check port availability
netstat -tlnp | grep 3000
# Verify dependencies
npm list
# Check Node.js version
node --version
Solutions:
-
Port Conflicts
-
Missing Dependencies
-
Permission Issues
Authentication Issues¶
Invalid Token Errors¶
Symptoms: - 401 Unauthorized responses - Token validation failures - Access denied messages
Diagnosis:
# Test token validity
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://your-gitlab-instance.com/api/v4/user
# Check token permissions
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://your-gitlab-instance.com/api/v4/personal_access_tokens
Solutions:
- Token Expired
- Generate new personal access token in GitLab
- Update environment variables
-
Restart MCP server
-
Insufficient Permissions
-
Token Format Issues
OAuth Authentication Problems¶
Symptoms: - OAuth flow failures - Redirect URI mismatches - Invalid client credentials
Solutions:
-
Application Configuration
-
Redirect URI Configuration
- Ensure redirect URI matches exactly in GitLab application settings
- Check for trailing slashes
- Verify protocol (http vs https)
Performance Issues¶
Slow Response Times¶
Symptoms: - API calls take longer than expected - Timeout errors - High resource usage
Diagnosis:
# Monitor resource usage
top -p $(pgrep node)
# Check memory usage
free -h
# Monitor network latency
ping -c 10 your-gitlab-instance.com
# Profile API calls
curl -w "@curl-format.txt" -o /dev/null -s \
"http://localhost:3000/mcp/projects"
Solutions:
-
Enable Caching
-
Optimize Database Queries
-
Increase Resource Limits
Memory Leaks¶
Symptoms: - Gradually increasing memory usage - Out of memory errors - Server crashes
Diagnosis:
# Monitor memory over time
while true; do
ps -o pid,vsz,rss,comm -p $(pgrep node)
sleep 30
done
# Generate heap dump
node --inspect server.js
Solutions:
-
Update Dependencies
-
Profile Memory Usage
-
Implement Connection Pooling
API Troubleshooting¶
GitLab API Errors¶
Common Error Codes:
Code | Meaning | Solution |
---|---|---|
400 | Bad Request | Validate request format |
401 | Unauthorized | Check authentication |
403 | Forbidden | Verify permissions |
404 | Not Found | Check resource existence |
429 | Rate Limited | Implement retry logic |
500 | Server Error | Check GitLab server status |
Rate Limiting Issues:
Symptoms: - HTTP 429 responses - "Rate limit exceeded" messages - Requests being throttled
Solutions:
-
Implement Exponential Backoff
-
Request Batching
JavaScript// Batch multiple requests const batchRequests = async (requests) => { const batchSize = 10; const results = []; for (let i = 0; i < requests.length; i += batchSize) { const batch = requests.slice(i, i + batchSize); const batchResults = await Promise.all(batch); results.push(...batchResults); // Delay between batches if (i + batchSize < requests.length) { await sleep(1000); } } return results; };
MCP Protocol Errors¶
Invalid JSON-RPC Format:
Symptoms: - "Invalid request" errors - JSON parsing failures - Protocol violation messages
Solutions:
-
Validate Request Format
-
Check Content-Type Headers
Docker Issues¶
Container Won't Start¶
Symptoms: - Docker container exits immediately - Initialization failures - Environment variable issues
Diagnosis:
# Check container logs
docker logs gitlab-mcp
# Inspect container
docker inspect gitlab-mcp
# Check resource constraints
docker stats gitlab-mcp
Solutions:
-
Environment Variables
-
Volume Mounting Issues
Network Connectivity¶
Symptoms: - Cannot reach external services - DNS resolution failures - Port binding issues
Solutions:
-
Docker Network Configuration
-
Port Mapping
Logging and Debugging¶
Enable Debug Logging¶
# Environment variable
export LOG_LEVEL=debug
# Configuration file
echo "log_level: debug" >> config.yml
# Command line argument
node server.js --log-level=debug
Structured Logging¶
// Winston logger configuration
const winston = require('winston');
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.errors({ stack: true }),
winston.format.json()
),
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
new winston.transports.Console()
]
});
Health Checks¶
# Basic health check
curl http://localhost:3000/health
# Detailed system status
curl http://localhost:3000/status
# GitLab connectivity test
curl http://localhost:3000/test/gitlab
Getting Help¶
Log Analysis¶
When reporting issues, include:
-
System Information
-
Configuration
-
Relevant Logs
Community Support¶
- GitHub Issues: Report bugs and feature requests
- Documentation: Check the latest documentation
- Community Forum: Ask questions and share experiences
- Stack Overflow: Search for existing solutions
Professional Support¶
For enterprise customers: - Priority Support: Guaranteed response times - Dedicated Engineer: Assigned support engineer - Custom Solutions: Tailored troubleshooting - Emergency Hotline: 24/7 critical issue support
Prevention¶
Monitoring Setup¶
# Prometheus metrics
metrics:
enabled: true
endpoint: /metrics
interval: 15s
# Health checks
health_checks:
- name: gitlab_connectivity
endpoint: /api/v4/version
interval: 60s
- name: database_connection
type: database
interval: 30s
Automated Testing¶
# Integration tests
npm run test:integration
# Performance tests
npm run test:performance
# Security tests
npm run test:security
Regular Maintenance¶
#!/bin/bash
# maintenance.sh - Run weekly
# Update dependencies
npm update
# Clean logs
find logs/ -name "*.log" -mtime +30 -delete
# Restart services
docker-compose restart
# Run health checks
npm run health-check
Conclusion¶
Regular monitoring, proper logging, and preventive maintenance significantly reduce troubleshooting needs. When issues arise, systematic diagnosis and the solutions provided in this guide should resolve most problems quickly.
For complex issues not covered here, consider: 1. Checking the latest documentation 2. Searching community forums 3. Contacting professional support 4. Contributing back to the community