Back to MCP directory
publicPublicdnsLocal runtime

git-mcp-server

一个基于Model Context Protocol的Git服务器,为AI助手和LLM代理提供标准化的Git仓库管理接口

article

README

🚀 Git MCP 服务器

Git MCP 服务器是基于模型上下文协议(Model Context Protocol)的版本控制系统。它通过统一接口,提供 Git 仓库的操作与数据查询功能,支持分支管理、远程仓库配置等多种 Git 操作,还能以标准资源格式展示 Git 数据。

🚀 快速开始

Git MCP 服务器为用户提供了便捷的方式来管理和查询 Git 仓库。通过简单的安装步骤,你就能快速启动并使用它。

✨ 主要特性

  • 基于模型上下文协议实现,提供统一接口进行 Git 仓库操作和数据查询。
  • 支持多种常见的 Git 操作,如分支管理、远程仓库配置、提交历史查看等。
  • 通过标准资源格式 expose Git 数据,方便与其他系统集成。

📦 安装指南

环境要求

  • 操作系统:Linux、macOS 或 Windows(推荐使用 Linux)
  • Node.js:版本 14.0 或更高
  • npm:版本 6.0 或更高
  • Git:版本 2.35 或更高

安装步骤

  1. 克隆仓库:
git clone git://github.com/yourusername/git-mcp-server.git
cd git-mcp-server
  1. 安装依赖:
npm install
  1. 启动服务器:
node index.js

📚 详细文档

资源描述

Git MCP 服务器通过标准资源格式 expose Git 数据,以下是主要资源接口:

| 资源路径 | 描述 | | ---- | ---- | | git://repo/{repoPath}/info | 提供 Git 仓库的基本信息,包括当前分支、状态和引用详情 | | git://repo/{repoPath}/branches | 列出仓库中的所有分支及当前分支标识 | | git://repo/{repoPath}/remotes | 显示仓库中配置的所有远程仓库及其 URL | | git://repo/{repoPath}/tags | 展示仓库中的所有标签及其引用信息 | | git://repo/{repoPath}/file/{filePath}?ref={ref} | 返回指定文件在特定 Git 引用下的内容 | | git://repo/{repoPath}/ls/{dirPath}?ref={ref} | 列出特定路径和引用下目录中的文件和子目录 | | git://repo/{repoPath}/diff/{fromRef}/{toRef}?path={path} | 提供两个 Git 引用(如提交、分支、标签)之间的差异报告 | | git://repo/{repoPath}/diff-unstaged?path={path} | 展示工作目录中所有未 staged 变更的 diff 信息 | | git://repo/{repoPath}/diff-staged?path={path} | 返回索引中的所有 staged 变更的 diff 内容 | | git://repo/{repoPath}/log?maxCount={maxCount}&file={file} | 获取提交历史记录,支持指定最大返回数量和特定文件 | | git://repo/{repoPath}/blame/{filePath} | 提供按行追溯信息,显示每个代码行最近修改的提交详情 | | git://repo/{repoPath}/commit/{commitHash} | 展示特定提交的详细信息,包括变更 diff 等 |

开发指南

构建与测试

# 构建项目
npm run build

# 监控文件变化并自动重建
npm run watch

# 使用 MCP 检查工具进行本地测试
npm run inspector

# 清理构建产物
npm run clean

# 生成文档目录树视图
npm run tree

# 完全清理后重新构建
npm run rebuild

📄 许可证

本项目遵循 Apache License 2.0 协议,具体详情请参阅 LICENSE 文件。


基于模型上下文协议构建
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client