git-mcp-server AGENTS.md

Repository instructions for developing git-mcp-server, a local service that gives an AI agent 29 Git tools for working with code repositories.

In plain words
What is it for?
Use them when changing, testing, packaging, or validating the git-mcp-server project.
Why use it?
They document the project's tests, linting, architecture rules, path checks, and precautions for destructive Git actions.

Instructions file for CodexOpenCode

Install

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.

agentmods
npx agentmods add instructions/jesspig/git-mcp-server/agents-md
Clone the repo
git clone --depth 1 https://github.com/jesspig/git-mcp-server

Made for: Codex, OpenCode.

Per session 1,480 This file is loaded in full into every session.
When invoked 1,480 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce 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

Measured yesterday against content hash bcb7c7609ee6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

AGENTS.md · 66 lines

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.pyTOOL_MODELS 是工具权威清单,server.py 用 getattr(tools, name) 分发。新增/改名工具必须同步 3 处:TOOL_MODELS + tools.py 聚合 re-export + server.py 顶部 READONLY_TOOLS/DESTRUCTIVE_TOOLS 注解集合
  • docstring 第一段 = MCP 工具描述:server.py _tool_descriptiondoc.strip().split("\n\n")[0]。工具 docstring 第一段必须自包含:摘要 + Best for: + Returns: + 提示,段内用换行不用空行;空行后的 Args 等不进 MCP 描述
  • 路径校验分流(server.py call_tool):git_init/git_clonevalidate_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 HEADrepo.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 时

Read the full file on GitHub · 66 lines

Changes

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.

  1. yesterday First seen · 66 lines · 1,480 tokens per session scan A bcb7c7609ee6

Subscribe to this mod's changes

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.

Related

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.

github/spec-kit · 7,104 tokens

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.

openai/codex · 5,182 tokens

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).

microsoft/vscode · 6,785 tokens

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.

langchain-ai/langchain · 4,345 tokens

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).

microsoft/vscode · 5,001 tokens

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.

vercel/next.js · 7,296 tokens