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 分