Git Mcp Server

io.github.Ray0907由 GitHub 帳號 Ray0907 發布v0.2.3更新於 Oct 24, 2026

MCP server for GitLab and GitHub

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理讀取與修改 GitHub 或 GitLab 的儲存庫、議題、合併請求、CI 流程與留言。

可以做什麼
  • 讀取與搜尋儲存庫內容:檔案內容、目錄結構、分支、提交歷史與程式碼搜尋
  • 寫入儲存庫:以單次提交推送檔案變更、建立分支
  • 讀取、列出、建立與更新議題
  • 讀取、列出、建立、查看差異並合併拉取/合併請求
  • 查看 CI/CD 流程與工作流程執行、列出作業並取得作業日誌
  • 在議題與合併請求上新增與列出留言,並查詢目前驗證的使用者
適用情境
適合希望助理在桌面用戶端直接操作 GitHub 或 GitLab 專案的情境:審閱程式碼與合併請求、處理議題、查看流程狀態,或不必離開對話就能提交少量檔案變更。
執行需求
透過 npx 從 npm 套件在本機執行,需要 Node.js。需在 GIT_TOKEN 提供個人存取權杖(GitHub 權限 repo、read:org、workflow;GitLab 權限 api、read_api、read_repository、write_repository)。GIT_PROVIDER 選擇 github 或 gitlab(預設 gitlab);GIT_API_URL 用於自架或 Enterprise 執行個體。需要能連線至服務商 API 的網路。
安裝前請注意
此權杖具備相當廣泛的儲存庫權限,包含寫入權限,並存放在用戶端設定檔中。寫入類工具可推送提交、建立分支、建立或合併合併請求、建立與更新議題、張貼留言。若只需讀取,可將 GIT_READ_ONLY 設為 true 以停用寫入操作。所有請求都會送往所設定的服務商 API 位址。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Git Mcp Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Git MCP Server

A clean, modular Git MCP server supporting both GitHub and GitLab.

Quick Start

Claude Desktop Configuration

Add to your claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

GitHub
json
{  "mcpServers": {    "git": {      "command": "npx",      "args": ["-y", "@raytien/git-mcp-server"],      "env": {        "GIT_PROVIDER": "github",        "GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"      }    }  }}
GitHub Enterprise
json
{  "mcpServers": {    "git": {      "command": "npx",      "args": ["-y", "@raytien/git-mcp-server"],      "env": {        "GIT_PROVIDER": "github",        "GIT_API_URL": "https://github.your-company.com/api/v3",        "GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"      }    }  }}
GitLab.com (SaaS)
json
{  "mcpServers": {    "git": {      "command": "npx",      "args": ["-y", "@raytien/git-mcp-server"],      "env": {        "GIT_PROVIDER": "gitlab",        "GIT_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx"      }    }  }}
Self-Hosted GitLab
json
{  "mcpServers": {    "git": {      "command": "npx",      "args": ["-y", "@raytien/git-mcp-server"],      "env": {        "GIT_PROVIDER": "gitlab",        "GIT_API_URL": "https://gitlab.your-company.com/api/v4",        "GIT_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx"      }    }  }}
Read-Only Mode
json
{  "mcpServers": {    "git": {      "command": "npx",      "args": ["-y", "@raytien/git-mcp-server"],      "env": {        "GIT_PROVIDER": "github",        "GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx",        "GIT_READ_ONLY": "true"      }    }  }}

Get Your Token

GitHub
  1. Go to GitHub > Settings > Developer settings > Personal access tokens > Tokens (classic)
  2. Generate new token with scopes: repo, read:org, workflow
  3. Copy the token (starts with ghp_)
GitLab
  1. Go to GitLab > Settings > Access Tokens
  2. Create a new token with scopes: api, read_api, read_repository, write_repository
  3. Copy the token (starts with glpat-)

Available Tools

Repository

ToolDescription
get_file_contentsRead file content from repository
get_repository_treeList directory structure
push_filesPush file changes in a single commit
create_branchCreate a new branch
list_branchesList repository branches
list_commitsList commit history
search_codeSearch for code in repository

Issues

ToolDescription
get_issueGet a single issue
list_issuesList issues
create_issueCreate a new issue
update_issueUpdate an issue

Pull/Merge Requests

ToolDescription
get_pull_requestGet a merge request
list_pull_requestsList merge requests
create_pull_requestCreate a merge request
get_pull_request_diffsGet merge request changes
merge_pull_requestMerge a merge request

CI/CD (Pipelines / Workflow Runs)

ToolDescription
get_pipelineGet pipeline/workflow run status
list_pipelinesList pipelines/workflow runs
list_pipeline_jobsList pipeline jobs/workflow jobs
get_job_logGet job log output

Note: GitHub Actions workflow runs map to GitLab pipelines. The same tools work for both platforms.

Comments

ToolDescription
create_commentAdd comment to issue/MR
list_commentsList comments

Users

ToolDescription
get_meGet current authenticated user

Configuration

Environment VariableRequiredDefaultDescription
GIT_PROVIDERNogitlabProvider type: gitlab or github
GIT_TOKENYes-Personal Access Token
GIT_API_URLNoProvider defaultAPI URL (auto-detected from provider)
GIT_AUTH_TYPENobearerAuth type: bearer or private-token
GIT_READ_ONLYNofalseDisable write operations
LOG_LEVELNoinfoLog level: debug, info, warn, error

Architecture

src/├── index.ts              # Entry point├── server.ts             # MCP server (provider-agnostic)├── config.ts             # Configuration (multi-provider)├── providers/            # Platform abstraction│   ├── interface.ts      # GitProvider interface│   ├── types.ts          # Platform-agnostic types│   ├── config.ts         # Provider configuration│   ├── factory.ts        # Provider Factory (creates GitLab/GitHub)│   ├── gitlab/           # GitLab implementation│   └── github/           # GitHub implementation├── tools/                # Tool definitions│   ├── define.ts         # defineTool helper│   ├── registry.ts       # Tool registry│   ├── repository/       # Repository tools│   ├── issues/           # Issue tools│   ├── merge-requests/   # PR/MR tools│   ├── pipelines/        # CI/CD tools│   ├── notes/            # Comment tools│   └── users/            # User tools├── gitlab/               # GitLab API client│   ├── client.ts         # HTTP client│   └── types.ts          # GitLab API types├── github/               # GitHub API client│   ├── client.ts         # HTTP client│   └── types.ts          # GitHub API types├── auth/                 # Authentication└── lib/                  # Utilities

Development

bash
# Install dependenciesnpm install
# Buildnpm run build
# Run testsnpm test
# Run locallynpm start
# Development mode (watch)npm run dev

Adding a New Tool

  1. Create file: src/tools/{category}/{action}.ts
typescript
import { z } from 'zod';import { defineTool, repoParam } from '../define.js';
const schema = z.object({    repo: repoParam,    // ... your params});
export const myTool = defineTool({    name: 'my_tool',    description: 'What this tool does',    schema,    category: 'my-category',    read_only: true,    handler: async (input, ctx) => {        return ctx.provider.repository.someMethod(input.repo, ...);    },});
  1. Export from category index: src/tools/{category}/index.ts
  2. Add to allTools: src/tools/index.ts

Inspired By

License

MIT

來源:README.md,提交 8c0ae3a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.3最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分