Skip to main content
Gitlab

Gitlab

Discover GitLab projects, groups, and merge requests. Provides MCP tools for GitLab operations.

The GitLab molecule automatically syncs GitLab data into your SixDegree ontology and gives AI agents tools to interact with GitLab projects.

  • SixDegree Platform installed
  • GitLab personal access token with api scope
  • For self-hosted GitLab: custom base URL

discovery:
enabled: true
settings:
# GitLab API credentials
token: "glpat-your_gitlab_token"

# Optional: Self-hosted GitLab URLs
base_url: "https://gitlab.com"
api_url: "https://gitlab.com/api/v4"

# Groups to discover
selectors:
- group: "your-group"
project_pattern: ".*" # Regex: all projects
graph_files:
- ".sixdegree.yaml" # Read graph definitions from projects

- group: "another-group"
project_pattern: "^backend-.*" # Only backend projects

# Optional: Webhook configuration
webhook:
secret: "your_webhook_secret"
events:
- push
- merge_request
- issue

mcp:
enabled: true
settings:
token: "glpat-your_gitlab_token"
base_url: "https://gitlab.com"

namespace: "production"

The GitLab molecule discovers:

  • entities.sixdegree.ai/v1/GitlabProject - GitLab projects with metadata (stars, language, description)

  • entities.sixdegree.ai/v1/GitlabHostingService - GitLab instance information

  • HOSTED_BY - Project is hosted by GitLab instance

Projects can include a .sixdegree.yaml file that defines additional entities and relationships. The molecule will read these files and add the custom graph data to your ontology.

AI agents can use these GitLab tools:

Create a new issue in a project.

Parameters:

  • project (string, required) - Project path (e.g., group/project)
  • title (string, required) - Issue title
  • description (string, optional) - Issue description in Markdown

Example:

User: "Create a GitLab issue in mygroup/myproject about the login bug"

AI: [Calls gitlab_create_issue]
"✅ Created issue #123: Fix login bug
https://gitlab.com/mygroup/myproject/-/issues/123"

Create a new merge request.

Parameters:

  • project (string, required) - Project path (e.g., group/project)
  • title (string, required) - MR title
  • description (string, optional) - MR description in Markdown
  • source_branch (string, required) - Source branch
  • target_branch (string, required) - Target branch

Example:

User: "Create an MR from feature-auth to main"

AI: [Calls gitlab_create_merge_request]
"✅ Created MR !45: Add authentication feature
https://gitlab.com/mygroup/myproject/-/merge_requests/45"

Get the contents of a file from a project.

Parameters:

  • project (string, required) - Project path (e.g., group/project)
  • path (string, required) - File path in project
  • ref (string, optional) - Git ref (branch, tag, or commit SHA)

Example:

User: "What's in the README of mygroup/myproject?"

AI: [Calls gitlab_get_file_contents]
"The README contains: [file contents]"

Runs on schedule to discover projects:


degree discovery run gitlab@1.0.0 --config gitlab-config.yaml


degree discovery schedule gitlab@1.0.0 --config gitlab-config.yaml --interval 5m

Real-time updates via GitLab webhooks:

  1. Configure webhook secret in your config
  2. Deploy webhook endpoint with SixDegree
  3. Add webhook to GitLab group settings:
    • URL: https://your-sixdegree.com/webhooks/gitlab
    • Secret token: Your webhook secret
    • Trigger: Push events, Merge request events, Issues events

degree discovery run gitlab@1.0.0 --config gitlab-config.yaml


degree discovery run gitlab@1.0.0 --config gitlab-config.yaml --dry-run


GITLAB_LOG_LEVEL=debug degree discovery run gitlab@1.0.0 --config gitlab-config.yaml

Once configured, AI agents can use GitLab tools:

You: "Create an issue in mygroup/api-service about rate limiting"

AI: ✅ Created issue #89: Implement rate limiting
https://gitlab.com/mygroup/api-service/-/issues/89

You: "What files are in the src/ directory of mygroup/frontend?"

AI: [Uses gitlab_get_file_contents to explore]
Found: src/App.js, src/index.js, src/components/...

cd gitlab
go build -o ../bin/gitlab


cd ..
make dev

For self-hosted GitLab installations:

discovery:
settings:
base_url: "https://gitlab.company.com"
api_url: "https://gitlab.company.com/api/v4"
token: "glpat-company_token"

Required GitLab token scopes:

  • Discovery: api (full API access), read_api (read-only)

  • MCP Tools: api (create issues/MRs)

  • Store tokens as secrets in your configuration

  • Use separate tokens for discovery and MCP if needed

  • Limit token scopes to minimum required permissions

  • Use webhook secrets to verify webhook authenticity

  • For production, use project or group access tokens

"404 Not Found" errors:

  • Check token has access to the group
  • Verify group name is correct
  • Ensure token has required scopes

Missing projects:

  • Check project_pattern regex matches project names
  • Verify token has access to private projects
  • Enable debug logging to see what's being discovered

Webhook not triggering:

MIT - See LICENSE file in molecules directory