Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/jesspig/git-mcp-server/agents-mdgit clone --depth 1 https://github.com/jesspig/git-mcp-serverWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01480 | $0.01480 |
| Opus 5 | $0.00740 | $0.00740 |
| Sonnet 5 | $0.00296 | $0.00296 |
| Haiku 4.5 | $0.00148 | $0.00148 |
Grade A, and why
git-mcp-server AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 66 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
项目定位
本地 Git MCP 服务器(stdio 传输):29 个 git 工具经 GitPython 暴露为 MCP 工具,返回文本结果。不发布 PyPI,入口 [project.scripts] git-mcp-server = "main:main"。工具清单见 schemas.TOOL_MODELS(用户已确认工具范围,勿增减)。
开发命令
- 全量测试:
uv run pytest tests -q(164 个,约 2.5 分钟) - 单模块:
uv run pytest tests/test_branch.py -q - lint:
uv run ruff check .(零告警为验收标准) - 启动验证:
uvx --from . git-mcp-server(.opencode/opencode.json已以此方式自举接入本仓库)
架构关键点(易踩坑)
- 非包结构:所有模块为顶层 .py(setuptools
py-modules)。新增 .py 必须同步 pyproject.toml 的py-modules列表,否则打包丢失 - 注册表驱动:
schemas.py的TOOL_MODELS是工具权威清单,server.py 用getattr(tools, name)分发。新增/改名工具必须同步 3 处:TOOL_MODELS + tools.py 聚合 re-export + server.py 顶部READONLY_TOOLS/DESTRUCTIVE_TOOLS注解集合 - docstring 第一段 = MCP 工具描述:server.py
_tool_description取doc.strip().split("\n\n")[0]。工具 docstring 第一段必须自包含:摘要 +Best for:+Returns:+ 提示,段内用换行不用空行;空行后的 Args 等不进 MCP 描述 - 路径校验分流(server.py call_tool):
git_init/git_clone走validate_target_path(目标可不存在);git_worktree(add/remove 且带 worktree_path)额外走validate_target_path(worktree_path);其余含repo_path的工具走validate_repo_path(要求存在)。GIT_MCP_ALLOWED_DIRS未设置时回退服务器工作目录为隐式沙箱 - repo_path 默认:所有工具
repo_path/local_path默认"."(服务器工作目录),agent 可省略 - 破坏性工具 preview 两阶段:
git_reset/git_checkout(force)/git_clean支持 preview(或 dry_run)先行查看影响,confirmed=True才执行;preview 优先于 confirmed(预览不执行、不要求 confirmed) - 错误约定:工具抛 ValueError(消息英文,四要素:事实·位置·期望);server 层统一转 is_error:ValueError/ValidationError 原样文本、GitError/OSError 加
Git operation failed:前缀、兜底Unexpected error: ...。禁止让未捕获异常击穿连接 - 空目录校验:git_init/git_clone/git_worktree 统一走
security.prepare_dir(path_str, what, create)(create=True 时自动 mkdir,False 时缺失即通过) - detached HEAD:
repo.head.ref在 detached 时抛 TypeError,须用repo.head.is_detached判断(git_branch 已示范)
破坏性确认(confirmed 参数)
8 个工具带 confirmed 参数,未传 True 时抛 ValueError:
| 工具 | 条件 |
|---|---|
| git_clean | 必需(dry_run=True 预览可免;无 force 参数) |
| git_reset | 必需 |
| git_branch | delete 时 |
| git_tag | delete 时 |
| git_stash | drop 时 |
| git_worktree | remove 时 |
| git_push | force=True 时 |
| git_checkout | force=True 时 |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 66 lines · 1,480 tokens per session scan A bcb7c7609ee6
git-mcp-server AGENTS.md is an instructions file published in the GitHub repository jesspig/git-mcp-server (0 stars, last pushed 24d ago), licensed MIT. It adds 1,480 tokens to every session, about $0.0074 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
spec-kit AGENTS.md
AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
next.js AGENTS.md
Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.