Repository avatar
Version Control
v0.3.2
active

efficient-gitlab

io.github.detailobsessed/efficient-gitlab

GitLab MCP Server with progressive disclosure - 5 meta-tools, 90% token reduction

Documentation

Efficient GitLab MCP

npm version CI License: MIT Bun MCP GitLab TypeScript Biome

Token-Efficient GitLab Server Management — An enhanced fork of zereight/gitlab-mcp with progressive disclosure pattern for dramatic token savings.

What's Different From Upstream?

This fork builds on the original GitLab MCP with substantial engineering improvements:

AreaUpstreamThis Fork
RuntimeNode.js + npmBun (faster builds, native TypeScript)
Tool Exposure100+ tools directly5 meta-tools (progressive disclosure)
TestingBasicComprehensive test suite
LintingESLint + PrettierStrict Biome rules (noExplicitAny, noNonNullAssertion, cognitive complexity)
CI/CDBasicGitHub Actions (lint, build, test, semantic-release)
Pre-commitNoneprek hooks (typos, formatting, build verification)

Key Improvements

  • Progressive Disclosure — 5 meta-tools instead of 100+ individual tools (~90% token reduction)
  • MCP Protocol Logging — Structured logs sent to LLM clients for agent observability
  • HTTP Transport Security — DNS rebinding protection, configurable allowed hosts/origins
  • Comprehensive Test Suite — 120+ tests covering registry, config, logger, MCP integration, and meta-tools
  • Strict Code Quality — Zero any types, no non-null assertions, enforced cognitive complexity limits
  • Modern Tooling — Bun for fast builds, Biome for linting, prek for pre-commit hooks
  • Automated Releases — Semantic versioning with conventional commits

How It Works

Instead of exposing 100+ individual tools, this server exposes 5 meta-tools:

Meta-ToolPurpose
list_categoriesDiscover available tool categories
list_toolsList tools in a specific category
search_toolsSearch for tools by keyword
get_tool_schemaGet full parameter schema for a tool
execute_toolExecute any GitLab tool by name

Token Savings

ApproachTools ExposedApproximate Token Cost
Traditional100+ tools~20,000+ tokens
Progressive Disclosure5 meta-tools~1,500 tokens

~90% reduction in tool definition tokens!

Example Workflow

1. LLM calls list_categories() → sees "merge-requests" category
2. LLM calls list_tools("merge-requests") → sees "create_merge_request", "merge_merge_request", etc.
3. LLM calls get_tool_schema("create_merge_request") → sees required params
4. LLM calls execute_tool("create_merge_request", {projectId: "123", title: "Fix bug", sourceBranch: "fix", targetBranch: "main"})

Available Operations

All GitLab operations organized by category:

CategoryDescription
repositoriesSearch, create, fork repos. Get files, push files, manage branches
merge-requestsCreate, update, merge MRs. Discussions, threads, diffs
issuesCreate, update, delete issues. Links, discussions
pipelinesList, create, retry, cancel pipelines. Job output
projectsProject details, members, labels
commitsList commits, get diffs
namespacesList, get, verify namespaces
searchGlobal, project, and group search across code, issues, MRs, commits
milestonesCreate, edit, delete milestones
wikiWiki page management
releasesRelease management
usersUser details
notesComments on issues and MRs
eventsUser and project activity
groupsGroup projects and iterations

Quick Start

Prerequisites

  • Node.js 18+ (for npx) or Bun 1.0+ (for bunx)
  • A GitLab personal access token with the following scopes:
    • api — Full API access (required for most operations)
    • read_api — Read-only API access (if you only need read operations)
    • read_repository — Read repository files
    • write_repository — Push to repositories

MCP Client Configuration

Add this to your MCP client configuration (e.g., ~/.config/claude/claude_desktop_config.json for Claude Desktop, or your IDE's MCP settings):

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["efficient-gitlab-mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx",
        "GITLAB_API_URL": "https://gitlab.com"
      }
    }
  }
}

Or with Bun:

{
  "mcpServers": {
    "gitlab": {
      "command": "bunx",
      "args": ["efficient-gitlab-mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx",
        "GITLAB_API_URL": "https://gitlab.com"
      }
    }
  }
}

For self-hosted GitLab, update GITLAB_API_URL to your instance URL.

Connect via CLI

# stdio transport (default)
claude mcp add gitlab-agent -- npx efficient-gitlab-mcp-server

# HTTP transport (requires running from source)
STREAMABLE_HTTP=true npx efficient-gitlab-mcp-server
claude mcp add --transport http gitlab-agent http://localhost:3002/mcp

Install from Source (Development)

git clone https://github.com/detailobsessed/efficient-gitlab-mcp.git
cd efficient-gitlab-mcp
bun install
bun run build
bun start

Features

MCP Protocol Logging

The server supports MCP protocol logging for agent observability. When connected, LLM clients can receive structured log messages showing what the server is doing:

  • Tool execution logs
  • GitLab API call details
  • Error information with context

This helps agents understand server behavior and debug issues.

HTTP Transport Security

When using HTTP transport (STREAMABLE_HTTP=true), the server includes security features:

Environment VariableDefaultDescription
HTTP_ALLOWED_HOSTSlocalhost,127.0.0.1Comma-separated list of allowed Host headers
HTTP_ALLOWED_ORIGINS(any)Comma-separated list of allowed Origin headers
HTTP_ENABLE_DNS_REBINDING_PROTECTIONtrueEnable DNS rebinding attack protection

Example for production:

HTTP_ALLOWED_HOSTS=api.example.com,localhost \
HTTP_ALLOWED_ORIGINS=https://app.example.com \
STREAMABLE_HTTP=true \
bun start

Development

# Run tests
bun test

# Run tests with coverage
bun test --coverage

# Lint and format
bun run check

# Build
bun run build

Configuration

Core Settings

VariableRequiredDefaultDescription
GITLAB_PERSONAL_ACCESS_TOKENYes*-GitLab personal access token
GITLAB_API_URLNohttps://gitlab.comGitLab instance URL
GITLAB_PROJECT_IDNo-Default project ID
GITLAB_ALLOWED_PROJECT_IDSNo-Comma-separated allowed project IDs
GITLAB_READ_ONLY_MODENofalseDisable write operations
GITLAB_IS_OLDNofalseFor older GitLab instances

Transport Settings

VariableRequiredDefaultDescription
STREAMABLE_HTTPNofalseEnable HTTP transport
SSENofalseEnable SSE transport
PORTNo3002HTTP server port
HOSTNo127.0.0.1HTTP server host

Feature Flags

VariableRequiredDefaultDescription
USE_GITLAB_WIKINofalseEnable wiki tools
USE_MILESTONENofalseEnable milestone tools
USE_PIPELINENofalseEnable pipeline tools

Logging & Security

VariableRequiredDefaultDescription
LOG_LEVELNoinfodebug, info, warn, error
LOG_FORMATNoprettyjson, pretty
HTTP_ALLOWED_HOSTSNolocalhost,127.0.0.1Allowed Host headers
HTTP_ALLOWED_ORIGINSNo(any)Allowed Origin headers

Remote Authorization (Multi-tenant)

VariableRequiredDefaultDescription
REMOTE_AUTHORIZATIONNofalseEnable remote auth
ENABLE_DYNAMIC_API_URLNofalseAllow dynamic GitLab URLs
SESSION_TIMEOUT_SECONDSNo3600Session timeout
MAX_SESSIONSNo1000Maximum concurrent sessions
MAX_REQUESTS_PER_MINUTENo60Rate limit per session

*Or use OAuth authentication - see OAuth Setup Guide


Security

  • Never commit tokens — Use .env files (gitignored)
  • Rotate tokens — Regenerate periodically
  • Least privilege — Only grant necessary API scopes
  • Audit logs — Monitor API access

Acknowledgments

This project is a fork of zereight/gitlab-mcp. Thanks to the original author for the comprehensive GitLab API implementation.


Resources


License

MIT License — See LICENSE for details.


Efficient GitLab MCP
AI-Powered GitLab Management with Token Efficiency
Built with Bun and the Model Context Protocol