gait_mcp
一种模型上下文协议(MCP)服务器 Git人工智能跟踪(GAIT).
GAIT让AI助手跟踪对话、代码更改和上下文,就像Git跟踪源代码一样。此MCP服务器允许VS Code Copilot、Gemini CLI和Claude Desktop等工具持久化AI转弯、倒退历史、分支想法,并将内存与您的工作目录同步。
这给了你什么
- AI对话的自动版本控制
- Git风格的分支和还原用于AI推理
- 编辑器重启后仍能保留的持久内存
- 对代码工件(文件+内容)的一流支持
- 通过GAITHUB兼容服务器提供云支持的遥控器
安装依赖项
选项1:使用紫外线(推荐)
uv sync
uv run python -u gait_mcp.py选项2:使用pip
创建并激活虚拟环境:
python3 -m venv .venv
source .venv/bin/activate
# Windows: .venv\Scripts\activate升级pip并安装依赖项:
pip install -U pip
pip install mcp fastmcp gait-ai将MCP服务器添加到VS代码中
将GAIT MCP服务器添加到VS Code MCP配置中。
示例(Linux/macOS):
{
"servers": {
"gait": {
"type": "stdio",
"command": "/home/johncapobianco/GAITCOPILOT/bin/python",
"args": [
"-u",
"/home/johncapobianco/gait_mcp/gait_mcp.py"
],
"env": {
"GAITHUB_TOKEN": "your_gaithub_token_here"
}
}
}
}Windows11上的WSL/Ubuntu
此配置在WSL下可靠工作:
"gait": {
"type": "stdio",
"command": "wsl",
"args": [
"/home/johncapobianco/GAITCOPILOT/bin/python",
"-u",
"/home/johncapobianco/gait_mcp/gait_mcp.py"
],
"env": {
"GAITHUB_TOKEN": ""
}
}推荐:使用VS代码聊天说明(最佳效果)
VS Code Copilot支持通过Markdown文件持久化聊天指令,而不是手动粘贴提示。 这是使用GAIT的首选和最可靠的方法。
步骤1:创建指令文件夹
从你的repo的根:
.github/instructions/默认情况下,VS Code会使用以下设置自动扫描此位置:
chat.instructionsFilesLocations = { ".github/instructions": true }步骤2:创建GAIT指令文件
创建此文件:
.github/instructions/gait-mcp.md步骤3:添加增益跟踪规则
将您的GAIT MCP规则粘贴到该文件中。例如:
GAIT MCP Tracking Rules
These instructions override any default Copilot behavior related to file edits, tool usage, or conversation tracking.
Automatic tracking
Every time you create or modify a file, you MUST call gait_record_turn.
Artifacts
When calling gait_record_turn, you MUST include the full content of every file you created or changed in the artifacts parameter as a list:
[{'path': 'filename', 'content': 'full file contents'}]
Initialization
If GAIT is not initialized in the current directory, you MUST call gait_init before performing any other action.
Revert and resume protocol
If you call gait_revert:
You MUST NOT call gait_record_turn for that action
You MUST immediately call gait_resume
You MUST treat the output of gait_resume as the new ground truth
You MUST ignore any turns that occurred after the reverted commit
Consistency rules
If GAIT tracking is active, you MUST NOT skip recording turns.
If a turn cannot be recorded, you MUST explain why before continuing.步骤4:启用Copilot中的指令
在VS代码中:
- 打开Copilot聊天
- 打开聊天说明菜单
- 选择
gait-mcp.md
一旦选定,这些规则将在整个工作区中持续存在。
您不再需要为每个会话粘贴提示。
可选:手动副驾驶提示(回退)
如果您没有使用聊天说明,您仍然可以手动引导:
I want to track our session using the GAIT MCP tool.
First, call gait_init in this directory to ensure tracking is active.
For every task I give you, once you have written or modified code, you must call gait_record_turn.
In that call, include my prompt as user_text, your explanation as assistant_text, and include the full content of any files you created or changed in the artifacts parameter as:
[{'path': 'filename', 'content': 'code'}].
Do you understand these instructions?预期工作流程
- 打开项目目录
- 启用GAIT聊天指令
- 让副驾驶正常工作
自动增益:
- 记录每一个有意义的转折
- 将文件更改作为工件进行跟踪
- 允许还原、分支和恢复AI上下文
初始化后,GAIT应自动跟踪对话。
备注
回复后,gait_resume是真理的来源
- GAIT拒绝按设计在文件系统根目录进行初始化
- 副驾驶聊天记录不能删除,但GAIT历史记录可以倒回
- 在恢复之后,
gait_resume是真理的源泉
