git-intel-mcp
Git Intelligence MCP 服务器
一个轻量级的模型上下文协议(MCP)服务器,将 Git 历史转化为可操作的仓库洞察。
概述
Git Intelligence MCP 是一个本地 MCP 服务器,允许 AI 助手通过自然语言请求分析 Git 仓库历史。
无需手动运行 Git 命令和解读提交历史,兼容 MCP 的客户端即可调用专用工具来发现:
频繁变更的文件
贡献者所有权模式
随时间推移的代码变动量
该项目刻意保持轻量,使用官方 MCP Python SDK 和 GitPython 实现为单个 Python 文件。
Related MCP server: GitIntel
为什么选择 Git Intelligence?
Git 历史中包含有用的工程信号,但手动提取这些信号可能很繁琐。
借助 Git Intelligence,您可以提出如下问题:
"哪些文件变更最频繁?"
"有多少开发人员参与过
server.py的开发?"
"自 2026 年 1 月以来有多少代码发生了变更?"
MCP 服务器将这些自然语言请求转化为结构化的工具调用,并分析仓库的 Git 历史。
Natural Language
│
▼
MCP Client
│
▼
Git Intelligence MCP
│
┌───┼────────┐
▼ ▼ ▼
Hotspots Bus Factor Churn
│ │ │
└───┼────────┘
▼
Git Repository
│
▼
Repository Insights功能特性
功能 | 描述 |
热点分析 | 查找变更最频繁的文件 |
公交因子分析 | 统计某个文件的独立贡献者数量 |
代码变动分析 | 计算自某个日期以来新增和删除的行数 |
自然语言访问 | 允许 AI 客户端调用 Git 分析工具 |
本地仓库支持 | 直接对克隆的 Git 仓库进行操作 |
轻量架构 | 无需数据库或外部服务 |
MCP Inspector 支持 | 便于本地工具测试和调试 |
VS Code 支持 | 可作为 MCP 客户端直接连接到 VS Code |
可用的 MCP 工具
1. hotspots
识别在仓库提交历史中被变更最频繁的文件。
参数
参数 | 类型 | 默认值 | 描述 |
|
| 必填 | 本地 Git 仓库的路径 |
|
|
| 要返回的文件数量 |
示例提示词
Use Git Intelligence to find the top 5 hotspot files in this repository.示例工具调用
hotspots(
repo_path="E:/projects/my-repo",
top_n=5
)示例结果
42 commits — server.py
27 commits — README.md
18 commits — config.py
12 commits — utils.py
9 commits — tests/test_server.py频繁修改的文件可能是识别值得额外审查或测试的区域的实用信号。
2. bus_factor
确定有多少不同的贡献者修改过特定文件。
参数
参数 | 类型 | 描述 |
|
| 本地 Git 仓库的路径 |
|
| 要分析的文件 |
示例提示词
Use Git Intelligence to find how many developers have modified server.py.示例工具调用
bus_factor(
repo_path="E:/projects/my-repo",
file_path="server.py"
)示例结果
server.py: 3 distinct author(s) — Alice, Bob, Charlie较低的贡献者数量可能表明某个文件周围存在潜在的知识集中风险。
3. churn_since
计算自指定日期以来新增和删除的总行数。
参数
参数 | 类型 | 描述 |
|
| 本地 Git 仓库的路径 |
|
| 起始日期,格式为 |
示例提示词
Use Git Intelligence to calculate the code churn since 2026-01-01.示例工具调用
churn_since(
repo_path="E:/projects/my-repo",
since_date="2026-01-01"
)示例结果
Since 2026-01-01: +842 / -391 lines这提供了在给定时间段内新增和删除代码量的简单视图。
示例工作流
连接到兼容 MCP 的客户端后,您可以使用自然语言与仓库进行交互。
查找仓库热点
Use Git Intelligence to find the top 5 most frequently changed files.↓
hotspots()↓
Repository history↓
Top 5 hotspot files调查文件所有权
How many different developers have worked on server.py?↓
bus_factor()↓
Distinct contributors分析开发活动
How many lines have been added and removed since 2026-06-01?↓
churn_since()↓
Code churn statisticsMCP 客户端兼容性
该服务器使用 stdio 传输,适合本地兼容 MCP 的客户端。
已在以下环境中测试:
MCP Inspector — 本地开发和工具测试
VS Code — MCP 客户端集成
架构保持简单:
┌───────────────────┐
│ MCP Client │
│ │
│ MCP Inspector │
│ VS Code │
└─────────┬─────────┘
│
stdio
│
▼
┌───────────────────┐
│ Git Intelligence │
│ MCP Server │
├───────────────────┤
│ hotspots() │
│ bus_factor() │
│ churn_since() │
└─────────┬─────────┘
│
▼
┌───────────────────┐
│ Local Git Repo │
└───────────────────┘技术栈
Python 3.10+
MCP Python SDK
FastMCP
GitPython
Git
stdio 传输
服务器使用基于装饰器的 FastMCP API 将 Python 函数暴露为 MCP 工具。
项目结构
该项目刻意保持实现的最小化:
git-intel-mcp/
│
├── .vscode/
│ └── mcp.json
│
├── assets/
│
├── server.py
├── requirements.txt
├── README.md
└── .gitignore为什么使用单个 server.py?
该项目被设计为一个聚焦的 MCP 学习实现,而非大型生产应用。
将核心实现保留在单个文件中,使 MCP 架构易于理解:
Define Tool
↓
@mcp.tool()
↓
MCP Tool Schema
↓
MCP Client
↓
Tool Call
↓
GitPython
↓
Git Repository
↓
Result随着功能的增长,这些工具可以拆分为独立的模块。
安装
1. 克隆仓库
git clone https://github.com/s-zaid-13/git-intel-mcp.git
cd git-intel-mcp2. 创建虚拟环境
Windows
python -m venv venv
venv\Scripts\activatemacOS / Linux
python -m venv venv
source venv/bin/activate3. 安装依赖
pip install -r requirements.txt环境要求
mcp[cli]<2.0.0
gitpython本地运行
使用以下命令启动 MCP 服务器:
python server.py服务器使用 stdio 传输,因此不会启动传统的 Web 服务器。
它会等待兼容 MCP 的客户端建立连接。
使用 MCP Inspector 测试
MCP Inspector 提供了在本地测试 MCP 服务器的交互式环境。
运行:
mcp dev server.py然后:
连接到服务器
检查可用的工具
查看生成的模式
提供参数
执行工具
验证返回的结果
以下工具应可用:
hotspots
bus_factor
churn_since连接到 VS Code
MCP 服务器也可以直接连接到 VS Code。
创建:
.vscode/mcp.jsonWindows 示例配置:
{
"servers": {
"gitIntelligence": {
"type": "stdio",
"command": "E:\\Spiral Lab\\git-intel-mcp\\venv\\Scripts\\python.exe",
"args": [
"E:\\Spiral Lab\\git-intel-mcp\\server.py"
],
"cwd": "E:\\Spiral Lab\\git-intel-mcp"
}
}
}连接后,以下 MCP 工具应在 VS Code 中可被发现:
gitIntelligence
├── hotspots
├── bus_factor
└── churn_since示例请求:
Use Git Intelligence to find the top 5 hotspot files in this repository.工作原理
该服务器使用 FastMCP 构建。
通过 MCP SDK 装饰器暴露工具:
@mcp.tool()
def hotspots(repo_path: str, top_n: int = 10) -> str:
...FastMCP 使用函数签名和文档来生成 MCP 客户端可以发现和调用的工具定义。
完整流程为:
Python Function
│
▼
@mcp.tool()
│
▼
MCP Tool Definition
│
▼
MCP Client
│
▼
Tool Call
│
▼
GitPython
│
▼
Git History
│
▼
Analysis Result演示的 MCP 概念
工具
服务器暴露了三个可调用的 MCP 工具:
hotspots
bus_factor
churn_since这些工具允许 AI 客户端执行仓库分析。
客户端-服务器架构
MCP 客户端无需了解 Git 分析在内部是如何实现的。
它只需要知道:
哪些工具可用
它们接受哪些参数
它们返回哪些结果
MCP Client
│
│ MCP
▼
MCP Server
│
▼
Git Repositorystdio 传输
本地服务器使用 stdio 进行通信,这非常适合本地运行的 MCP 服务器和开发客户端。
局限性
该实现刻意保持较小的范围。
仅支持本地 Git 仓库。
大型仓库可能需要额外的处理时间。
变动量衡量的是变更的数量,而非代码质量。
这些局限性使项目专注于理解 MCP,而非构建完整的仓库分析平台。
学习成果
该项目演示了使用 Python 构建 MCP 服务器的基础知识:
使用官方 Python SDK 创建 MCP 服务器
使用
FastMCP定义工具理解 MCP 工具模式
使用 stdio 传输
将 MCP 服务器连接到 MCP 客户端
使用 MCP Inspector 测试工具
将自定义 MCP 与 VS Code 集成
为公开发布准备 MCP 项目
核心要点很简单:
MCP 为 AI 应用提供了一种标准化的方式来发现和交互外部工具与能力。
作者
Samama Zaid
作为学习和实现 使用 Python 的模型上下文协议 的实践项目而构建。
This server cannot be installed
Maintenance
Related MCP Servers
- FlicenseAqualityCmaintenanceAn MCP server that transforms repositories into queryable knowledge by combining static code analysis with git history tracking. It allows users to investigate codebase structure, identify fragile files based on churn, and receive risk assessments through natural language queries.7
- AlicenseAqualityBmaintenanceA local Git intelligence MCP server that provides deep repository analytics including hotspots, temporal coupling, knowledge maps, churn analysis, and risk scoring for AI agents.1212MIT
- AlicenseAqualityCmaintenanceA local Git intelligence MCP server that provides deep repository analytics including hotspots, churn, knowledge maps, and risk scoring, all computed from commit history without data leaving your machine.12MIT
- AlicenseNot gradedqualityCmaintenanceA production-grade MCP server for local git repositories that provides tools for code search, git history analysis, complexity metrics, test discovery, and dependency management.MIT
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
An MCP server that gives your AI access to the source code and docs of all public github repos
MCP server for static security analysis of Android source code
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/s-zaid-13/git-intel-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server