GitLab MCP Server

GitLab MCP Server

Enables AI agents to interact with GitLab repositories, monitor documentation changes, manage issues and merge requests, and search across projects with comprehensive file and commit operations.

Category
访问服务器

README

GitLab MCP Server for AgenticLedger

A Model Context Protocol (MCP) server that enables AI agents to interact with GitLab repositories, monitor documentation changes, and manage issues and merge requests.

Overview

This MCP server provides comprehensive GitLab integration for the AgenticLedger platform, enabling AI agents to:

  • Monitor Documentation Changes: Track commits, compare branches, and detect file modifications
  • Read Repository Contents: Access files, directory structures, and wiki pages
  • Manage Issues & MRs: Create and track issues, merge requests, and comments
  • Search Across GitLab: Find projects, code, commits, and more

Authentication Pattern

  • [x] API Key (Direct Personal Access Token)

Token Format

accessToken: "glpat-xxxxxxxxxxxxxxxxxxxx"

GitLab Personal Access Token (PAT) with appropriate scopes:

  • read_api - For read-only operations
  • read_repository - For file access
  • api - For full access (issues, MRs, wikis)

Creating a Token

  1. Go to GitLab > Settings > Access Tokens
  2. Create a new token with required scopes
  3. Copy the token (starts with glpat-)

Installation

# Clone the repository
git clone https://github.com/oregpt/Agenticledger_MCP_Gitlab.git
cd Agenticledger_MCP_Gitlab

# Install dependencies
npm install

# Build
npm run build

Configuration

For Claude Code / MCP Clients

Add to your MCP configuration:

{
  "mcpServers": {
    "gitlab": {
      "command": "node",
      "args": ["path/to/GitlabMCP/dist/index.js"],
      "env": {
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Environment Variables

Variable Required Default Description
GITLAB_API_URL No https://gitlab.com/api/v4 GitLab API base URL (for self-hosted instances)

Available Tools

Project Operations

gitlab_search_projects

Description: Search for GitLab projects by name or description.

Parameters:

  • accessToken (string, required): GitLab Personal Access Token
  • search (string, required): Search query
  • page (number, optional): Page number
  • per_page (number, optional): Results per page (1-100)

Example:

{
  "accessToken": "glpat-xxxx",
  "search": "documentation",
  "per_page": 10
}

gitlab_get_project

Description: Get detailed project information.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID or URL-encoded path

gitlab_list_group_projects

Description: List all projects in a group.

Parameters:

  • accessToken (string, required): GitLab PAT
  • group_id (string, required): Group ID or path
  • include_subgroups (boolean, optional): Include subgroup projects
  • search (string, optional): Filter by name
  • order_by (string, optional): Sort field
  • sort (string, optional): asc or desc

File Operations

gitlab_get_file_contents

Description: Read file contents from a repository. Essential for documentation monitoring.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • file_path (string, required): Path to file (e.g., "docs/README.md")
  • ref (string, optional): Branch, tag, or commit SHA

Response:

{
  "success": true,
  "data": {
    "file_name": "README.md",
    "file_path": "docs/README.md",
    "content": "# Documentation\n...",
    "encoding": "base64",
    "ref": "main"
  }
}

gitlab_get_tree

Description: List files and directories in a repository path.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • path (string, optional): Directory path
  • ref (string, optional): Branch/tag/SHA
  • recursive (boolean, optional): List recursively

gitlab_create_or_update_file

Description: Create or update a file with a commit.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • file_path (string, required): Target file path
  • branch (string, required): Target branch
  • content (string, required): File content
  • commit_message (string, required): Commit message

Commit Operations (Critical for Monitoring)

gitlab_list_commits

Description: List recent commits. Primary tool for detecting documentation changes.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • ref_name (string, optional): Branch or tag
  • since (string, optional): ISO 8601 date
  • until (string, optional): ISO 8601 date
  • path (string, optional): Filter by file path
  • author (string, optional): Filter by author email
  • with_stats (boolean, optional): Include stats

Example - Monitor docs folder:

{
  "accessToken": "glpat-xxxx",
  "project_id": "12345",
  "path": "docs/",
  "since": "2024-01-01T00:00:00Z",
  "with_stats": true
}

gitlab_get_commit_diff

Description: Get file changes for a specific commit.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • sha (string, required): Commit SHA

gitlab_compare

Description: Compare two branches/tags/commits.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • from (string, required): Source ref
  • to (string, required): Target ref

Activity Monitoring

gitlab_get_project_events

Description: Get recent project activity. Best tool for real-time monitoring.

Parameters:

  • accessToken (string, required): GitLab PAT
  • project_id (string, required): Project ID
  • action (string, optional): Filter by action type (pushed, commented, etc.)
  • target_type (string, optional): Filter by target (issue, merge_request, etc.)
  • after (string, optional): Events after this date (ISO 8601)
  • before (string, optional): Events before this date

Example - Monitor push events:

{
  "accessToken": "glpat-xxxx",
  "project_id": "12345",
  "action": "pushed",
  "after": "2024-12-01T00:00:00Z"
}

Issue Operations

gitlab_list_issues

List project issues with filtering.

gitlab_get_issue

Get specific issue details.

gitlab_create_issue

Create a new issue.

gitlab_list_issue_notes

List comments on an issue.


Merge Request Operations

gitlab_list_merge_requests

List MRs with filtering.

gitlab_get_merge_request

Get MR details.

gitlab_get_merge_request_changes

Get file changes in an MR.

gitlab_create_merge_request

Create a new MR.


Wiki Operations

gitlab_list_wiki_pages

List all wiki pages.

gitlab_get_wiki_page

Get wiki page content.

gitlab_create_wiki_page

Create a wiki page.

gitlab_update_wiki_page

Update a wiki page.


Search Operations

gitlab_search

Description: Search across GitLab.

Parameters:

  • accessToken (string, required): GitLab PAT
  • search (string, required): Search query
  • scope (string, optional): projects, issues, merge_requests, blobs, commits, etc.
  • project_id (string, optional): Limit to project
  • group_id (string, optional): Limit to group

Response Format

All tools return a standardized response:

{
  success: boolean;
  data?: any;      // Present on success
  error?: string;  // Present on failure
}

Success Example:

{
  "success": true,
  "data": {
    "id": 12345,
    "name": "my-project",
    "description": "..."
  }
}

Error Example:

{
  "success": false,
  "error": "Resource not found: /projects/99999"
}

Testing

# Run unit tests
npm test

# Run integration tests (requires GITLAB_TEST_TOKEN)
GITLAB_TEST_TOKEN=glpat-xxx npm run test:integration

Use Case: Documentation Monitoring

This is the primary use case for this MCP server. Here's how to monitor a customer's documentation repo:

Workflow

  1. Initial Scan: Use gitlab_get_tree to discover documentation files
  2. Monitor Changes: Periodically call gitlab_get_project_events or gitlab_list_commits
  3. Fetch Updates: When changes detected, use gitlab_get_file_contents to read updated files
  4. Process: Feed updated content to your D7 data pipeline

Example Monitoring Script

// 1. Get recent commits affecting docs
const commits = await gitlab_list_commits({
  accessToken: "glpat-xxx",
  project_id: "customer/docs-repo",
  path: "docs/",
  since: lastCheckTime,
  with_stats: true
});

// 2. For each new commit, get the changes
for (const commit of commits.data) {
  const diff = await gitlab_get_commit_diff({
    accessToken: "glpat-xxx",
    project_id: "customer/docs-repo",
    sha: commit.id
  });

  // 3. Process changed files
  for (const file of diff.data) {
    if (file.new_path.startsWith('docs/')) {
      const content = await gitlab_get_file_contents({
        accessToken: "glpat-xxx",
        project_id: "customer/docs-repo",
        file_path: file.new_path
      });
      // Update your knowledge base
    }
  }
}

Platform Integration Notes

Self-Hosted GitLab

Set GITLAB_API_URL to your instance:

{
  "env": {
    "GITLAB_API_URL": "https://gitlab.yourcompany.com/api/v4"
  }
}

Rate Limits

GitLab has rate limits:

  • Authenticated: 2000 requests/minute
  • Consider pagination for large datasets
  • Use since filters to reduce response size

Token Scopes

Minimum required scopes:

Operation Required Scope
Read files read_repository
Read issues/MRs read_api
Create issues/MRs api
Write files api

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes
  4. Run tests
  5. Submit a pull request

Support

For issues, please file a GitHub issue at: https://github.com/oregpt/Agenticledger_MCP_Gitlab/issues

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选