Skip to main content
Glama

GitLab MCP サーバー

✨ 特徴

  • 包括的な GitLab API 統合- リポジトリ、問題、マージ リクエスト、Wiki などにアクセスします

  • 両方のトランスポートをサポート- stdio または Server-Sent Events (SSE) で使用

  • 一貫したレスポンスフォーマット- 標準化されたページ区切りとレスポンス構造

  • 強力な TypeScript 型付け- 型安全性のために MCP SDK を使用して構築

  • 完全なドキュメント- 利用可能なすべてのツールの例

🔍 サポートされている操作

  • リポジトリ管理- リポジトリの検索、作成、フォーク

  • ファイル処理- ファイルの読み取り、作成、更新

  • ブランチ操作- ブランチの作成と管理

  • 問題追跡- 問題の作成、一覧表示、フィルタリング

  • マージリクエスト- マージリクエストの作成、一覧表示、レビュー

  • グループ管理- グループプロジェクトとメンバーの一覧

  • プロジェクトアクティビティ- イベントとコミット履歴を追跡

  • Wiki管理- 添付ファイル付きのプロジェクトおよびグループWikiを完全サポート

  • メンバー管理- プロジェクト/グループのメンバーを一覧表示して管理します

Related MCP server: gitlab mcp

🚀 はじめに

インストール

npmから(推奨)

npm install @yoda.digital/gitlab-mcp-server

ソースから

# Clone the repository
git clone https://github.com/yoda-digital/mcp-gitlab-server.git
cd mcp-gitlab-server

# Install dependencies
npm install

# Build the project
npm run build

構成

環境変数

サーバーには次の環境変数が必要です。

変数

必須

デフォルト

説明

GITLAB_PERSONAL_ACCESS_TOKEN

はい

-

GitLab個人アクセストークン

GITLAB_API_URL

いいえ

https://gitlab.com/api/v4

GitLab API URL

PORT

いいえ

3000

SSEトランスポート用のポート

USE_SSE

いいえ

false

SSEトランスポートを使用するには「true」に設定してください

GITLAB_READ_ONLY_MODE

いいえ

false

読み取り専用モードを有効にするには、「true」に設定します(下記参照)

読み取り専用モード

GITLAB_READ_ONLY_MODEtrueに設定されている場合、サーバーは読み取り操作のみを公開します。これは、GitLabリソースへの書き込みアクセス権を持たないクライアントアプリケーションに便利です。読み取り専用モードでは、以下のツールが利用可能になります。

  • search_repositories

  • get_file_contents

  • list_group_projects

  • get_project_events

  • list_commits

  • list_issues

  • list_merge_requests

  • list_project_wiki_pages

  • get_project_wiki_page

  • list_group_wiki_pages

  • get_group_wiki_page

  • list_project_members

  • list_group_members

読み取り専用モードで書き込み操作 (作成、更新、削除) を実行しようとすると、エラーが発生します。

MCP設定の構成

MCP 設定ファイルに GitLab MCP サーバーを追加します。

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["-y", "@yoda.digital/gitlab-mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "your_token_here",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      },
      "alwaysAllow": [],
      "disabled": false
    }
  }
}

読み取り専用モードの場合は、 GITLAB_READ_ONLY_MODE環境変数を追加します。

{
  "mcpServers": {
    "gitlab-readonly": {
      "command": "npx",
      "args": ["-y", "@yoda.digital/gitlab-mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "your_token_here",
        "GITLAB_API_URL": "https://gitlab.com/api/v4",
        "GITLAB_READ_ONLY_MODE": "true"
      },
      "alwaysAllow": [],
      "disabled": false
    }
  }
}

使用法

stdioトランスポートあり(デフォルト)

# Set your GitLab personal access token
export GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here

# Run the server
npm start

SSEトランスポート

# Set your GitLab personal access token and enable SSE
export GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here
export GITLAB_READ_ONLY_MODE=false
export USE_SSE=true
export PORT=3000  # Optional, defaults to 3000

# Run the server
npm start

npxの場合

# Run directly with npx
GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here npx @yoda.digital/gitlab-mcp-server

🛠️ 利用可能なツール

リポジトリ操作

{
  "search": "project-name",
  "page": 1,
  "per_page": 20
}
{
  "name": "new-project",
  "description": "A new project",
  "visibility": "private",
  "initialize_with_readme": true
}
{
  "project_id": "username/project",
  "namespace": "target-namespace"
}
{
  "group_id": "group-name",
  "archived": false,
  "visibility": "public",
  "include_subgroups": true,
  "page": 1,
  "per_page": 20
}

ファイル操作

{
  "project_id": "username/project",
  "file_path": "path/to/file.txt",
  "ref": "main"
}
{
  "project_id": "username/project",
  "file_path": "path/to/file.txt",
  "content": "File content here",
  "commit_message": "Add/update file",
  "branch": "main",
  "previous_path": "old/path/to/file.txt"
}
{
  "project_id": "username/project",
  "files": [
    {
      "path": "file1.txt",
      "content": "Content for file 1"
    },
    {
      "path": "file2.txt",
      "content": "Content for file 2"
    }
  ],
  "commit_message": "Add multiple files",
  "branch": "main"
}

支店運営

{
  "project_id": "username/project",
  "branch": "new-branch",
  "ref": "main"
}

発行業務

{
  "project_id": "username/project",
  "title": "Issue title",
  "description": "Issue description",
  "assignee_ids": [1, 2],
  "milestone_id": 1,
  "labels": ["bug", "critical"]
}
{
  "project_id": "username/project",
  "state": "opened",
  "labels": "bug,critical",
  "milestone": "v1.0",
  "author_id": 1,
  "assignee_id": 2,
  "search": "keyword",
  "created_after": "2023-01-01T00:00:00Z",
  "created_before": "2023-12-31T23:59:59Z",
  "updated_after": "2023-06-01T00:00:00Z",
  "updated_before": "2023-06-30T23:59:59Z",
  "page": 1,
  "per_page": 20
}
{
  "project_id": "username/project",
  "issue_iid": 42,
  "sort": "desc",
  "order_by": "created_at",
  "page": 1,
  "per_page": 20
}

応答形式:

{
  "count": 15,
  "notes": [
    {
      "id": 123456,
      "body": "This is a comment on the issue",
      "author": {
        "id": 1,
        "username": "username",
        "name": "User Name"
      },
      "created_at": "2023-01-01T00:00:00Z",
      "updated_at": "2023-01-01T00:00:00Z",
      "system": false,
      "type": "comment"
    },
    {
      "id": 123457,
      "body": "added label ~bug",
      "author": {
        "id": 1,
        "username": "username",
        "name": "User Name"
      },
      "created_at": "2023-01-02T00:00:00Z",
      "updated_at": "2023-01-02T00:00:00Z",
      "system": true,
      "type": "system"
    }
    // ... other notes
  ]
}
{
  "project_id": "username/project",
  "issue_iid": 42,
  "page": 1,
  "per_page": 20
}

応答形式:

{
  "count": 5,
  "discussions": [
    {
      "id": "discussion-123",
      "individual_note": true,
      "notes": [
        {
          "id": 123456,
          "body": "This is a comment on the issue",
          "author": {
            "id": 1,
            "username": "username",
            "name": "User Name"
          },
          "created_at": "2023-01-01T00:00:00Z",
          "updated_at": "2023-01-01T00:00:00Z",
          "system": false,
          "type": "comment"
        }
      ]
    },
    {
      "id": "discussion-124",
      "individual_note": false,
      "notes": [
        {
          "id": 123457,
          "body": "This is a thread starter",
          "author": {
            "id": 1,
            "username": "username",
            "name": "User Name"
          },
          "created_at": "2023-01-02T00:00:00Z",
          "updated_at": "2023-01-02T00:00:00Z",
          "system": false,
          "type": "comment"
        },
        {
          "id": 123458,
          "body": "This is a reply in the thread",
          "author": {
            "id": 2,
            "username": "username2",
            "name": "User Name 2"
          },
          "created_at": "2023-01-03T00:00:00Z",
          "updated_at": "2023-01-03T00:00:00Z",
          "system": false,
          "type": "comment"
        }
      ]
    }
    // ... other discussions
  ]
}

マージリクエスト操作

{
  "project_id": "username/project",
  "title": "Merge request title",
  "description": "Merge request description",
  "source_branch": "feature-branch",
  "target_branch": "main",
  "allow_collaboration": true,
  "draft": false
}
{
  "project_id": "username/project",
  "state": "opened",
  "order_by": "created_at",
  "sort": "desc",
  "milestone": "v1.0",
  "labels": "feature,enhancement",
  "created_after": "2023-01-01T00:00:00Z",
  "created_before": "2023-12-31T23:59:59Z",
  "updated_after": "2023-06-01T00:00:00Z",
  "updated_before": "2023-06-30T23:59:59Z",
  "author_id": 1,
  "assignee_id": 2,
  "search": "keyword",
  "source_branch": "feature-branch",
  "target_branch": "main",
  "page": 1,
  "per_page": 20
}

プロジェクト活動

{
  "project_id": "username/project",
  "action": "pushed",
  "target_type": "issue",
  "before": "2023-12-31T23:59:59Z",
  "after": "2023-01-01T00:00:00Z",
  "sort": "desc",
  "page": 1,
  "per_page": 20
}
{
  "project_id": "username/project",
  "sha": "branch-or-commit-sha",
  "path": "path/to/file",
  "since": "2023-01-01T00:00:00Z",
  "until": "2023-12-31T23:59:59Z",
  "all": true,
  "with_stats": true,
  "first_parent": true,
  "page": 1,
  "per_page": 20
}

メンバーオペレーション

{
  "project_id": "username/project",
  "query": "search term",
  "page": 1,
  "per_page": 20
}

応答形式:

{
  "count": 3,
  "items": [
    {
      "id": 123,
      "username": "username",
      "name": "User Name",
      "state": "active",
      "avatar_url": "https://gitlab.com/avatar.png",
      "web_url": "https://gitlab.com/username",
      "access_level": 50,
      "access_level_description": "Owner"
    }
    // ... other members
  ]
}
{
  "group_id": "group-name",
  "query": "search term",
  "page": 1,
  "per_page": 20
}

応答形式:

{
  "count": 5,
  "items": [
    {
      "id": 456,
      "username": "username",
      "name": "User Name",
      "state": "active",
      "avatar_url": "https://gitlab.com/avatar.png",
      "web_url": "https://gitlab.com/username",
      "access_level": 30,
      "access_level_description": "Developer"
    }
    // ... other members
  ]
}

プロジェクトWiki運営

{
  "project_id": "username/project",
  "with_content": false
}
{
  "project_id": "username/project",
  "slug": "page-slug",
  "render_html": false,
  "version": "commit-sha"
}
{
  "project_id": "username/project",
  "title": "Page Title",
  "content": "Wiki page content",
  "format": "markdown"
}
{
  "project_id": "username/project",
  "slug": "page-slug",
  "title": "New Page Title",
  "content": "Updated wiki page content",
  "format": "markdown"
}
{
  "project_id": "username/project",
  "slug": "page-slug"
}
{
  "project_id": "username/project",
  "file_path": "path/to/attachment.png",
  "content": "base64-encoded-content",
  "branch": "main"
}

グループWiki操作

{
  "group_id": "group-name",
  "with_content": false
}
{
  "group_id": "group-name",
  "slug": "page-slug",
  "render_html": false,
  "version": "commit-sha"
}
{
  "group_id": "group-name",
  "title": "Page Title",
  "content": "Wiki page content",
  "format": "markdown"
}
{
  "group_id": "group-name",
  "slug": "page-slug",
  "title": "New Page Title",
  "content": "Updated wiki page content",
  "format": "markdown"
}
{
  "group_id": "group-name",
  "slug": "page-slug"
}
{
  "group_id": "group-name",
  "file_path": "path/to/attachment.png",
  "content": "base64-encoded-content",
  "branch": "main"
}

🔧 開発

要件

  • Node.js 16以上

  • npm 7以上

  • 個人アクセストークンを持つGitLabアカウント

プロジェクトの構築

npm run build

テストの実行

npm test

コードスタイルとリンティング

npm run lint

リリースプロセス

  1. package.jsonのバージョンを更新する

  2. CHANGELOG.md を更新

  3. GitHubで新しいリリースを作成する

  4. npm publishで npm に公開する

📖 ドキュメント

より詳細なドキュメントについては、ドキュメント サイトにアクセスするか、ソース コード内の TypeScript 定義を確認してください。

💼 ユースケース

  • AIを活用した開発ワークフロー- AIアシスタントがGitLabリポジトリと対話できるようにします

  • 自動化された問題とPR管理- AIサポートによる開発プロセスの合理化

  • Wiki管理- ドキュメントの更新とナレッジベースの管理を自動化

  • チームコラボレーション- AIアシスタントをチームのGitLabワークフローに統合する

📊 ロードマップ

  • [ ] GitLab CI/CD統合

  • [ ] 高度なプロジェクト分析

  • [ ] 包括的なテストスイート

  • [ ] GitLab GraphQL APIのサポート

  • [ ] 拡張Webhookサポート

🤝 貢献する

貢献を歓迎します!貢献方法は以下の通りです。

  1. リポジトリをフォークする

  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature

  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )

  4. ブランチにプッシュする ( git push origin feature/amazing-feature )

  5. プルリクエストを開く

必要に応じてテストを更新し、プロジェクトのコード スタイルに従ってください。

📝 ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

👥 貢献者

このプロジェクトの改善に協力してくれたすべての貢献者に感謝します。

特別な感謝を申し上げます:

  • thomasleveil - プロジェクトとグループのGitLabメンバーリスト機能を実装し、一貫した応答フォーマットを実現しました。

📦 NPM パッケージ

このパッケージはnpmで入手できます:
https://www.npmjs.com/package/@yoda.digital/gitlab-mcp-server

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoda-digital/mcp-gitlab-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server