HomeMCP / Tooling公式MCP Gitサーバーに「変更なし」のままコミットを頼んだら、エラー無く何度でも積み上がった

公式MCP Gitサーバーに「変更なし」のままコミットを頼んだら、エラー無く何度でも積み上がったA hands-on investigation revealed that the official MCP Git server silently…

AI2 点サマリ2 key points
  • 公式MCPのGitサーバーに対してワーキングツリーに変更がない状態でコミットを依頼すると、エラーが返らず空コミットが際限なく積み重なることが確認された。
  • このバグはAIエージェントがGit操作を自動化する際の信頼性に影響する。
  • A hands-on investigation revealed that the official MCP Git server silently creates empty commits when asked to commit with no working-tree changes, stacking them indefinitely without errors.
  • This behavior poses a reliability risk when AI agents automate Git workflows.

要約と収集メタデータをもとに生成した AI 解説本文です。元記事全文の転載・翻訳ではありません。This AI explainer is generated from the summaries and collected metadata, not from a reproduction or translation of the full source article.

AIエージェントとツールを標準化された方法でつなぐ仕組みとして注目されるMCP(Model Context Protocol)だが、その公式実装の一つであるGitサーバーに、意図しない空コミットを生み出す挙動が確認された。ワーキングツリーに変更がない状態でコミットを依頼しても、エラーが返らずにコミットが際限なく積み重なるという。

検証によれば、対象となったのは公式が提供するMCP Gitサーバーで、変更がまったくない状態でコミット操作を実行しても処理が成功したかのように振る舞い、実質的に中身のない空コミットが作成される。通常のコマンドライン操作であれば、git commit は変更がない場合に「nothing to commit」といったメッセージを返して処理を中断する。しかし今回の挙動では同様のガードが働かず、繰り返し依頼するたびに空コミットが履歴に追加されていく点が問題視されている。

MCPはAnthropicが提唱したオープンな規格で、AIモデルが外部のデータソースやツールにアクセスするための共通インターフェースを定める。ファイル操作やデータベース参照、そしてGit操作などを担う「サーバー」を用意することで、対話型AIやエージェントが人手を介さずに実際の作業を進められるようになる。Gitサーバーはその代表的なリファレンス実装の一つで、コミットやブランチ操作といったバージョン管理をAIに委ねる用途が想定されている。

公式MCPのGitサーバーに対してワーキングツリーに変更がない状態でコミットを依頼すると、エラーが返らず空コミットが際限なく積み重なることが確認された。
🔗 MCP / Tooling · 本記事のポイント

この挙動が問題となるのは、AIエージェントがGitワークフローを自動化する場面だ。エージェントは処理の成否をサーバーからの戻り値で判断することが多く、エラーが返らなければ「コミットに成功した」と解釈して次の手順へ進む可能性がある。その結果、変更がないにもかかわらずコミットが繰り返され、履歴が無意味なエントリで膨らむおそれがある。人間のレビューを経ずに空コミットが積み上がれば、後からの差分確認や履歴の追跡が煩雑になりかねない。

背景には、Git自体が --allow-empty オプションによって空コミットを明示的に許可する設計を持つ点がある。空コミットはCIのトリガーなどに使われることもあり、一概に不正とは言えない。ただ、変更がない状態を暗黙のうちに空コミットとして扱う挙動は、利用者の想定と食い違う可能性が高い。AIエージェント向けのツール群はまだ発展途上であり、こうした細かな挙動の差異が自動化の信頼性を左右する。MCP関連のサーバーは各社やコミュニティで実装が広がりつつあるだけに、戻り値やエラーハンドリングの整合性をどう担保するかは今後の課題となりそうだ。

A hands-on investigation has surfaced a subtle but consequential flaw in the official Model Context Protocol (MCP) Git server: when an agent asks it to commit while the working tree contains no changes, the server does not raise an error but instead quietly produces an empty commit, and it will keep doing so on every subsequent request. For teams experimenting with AI agents that drive version control on their behalf, this behavior is worth understanding because it can silently pollute a repository's history without any signal that something has gone wrong.

The core issue is a divergence from how the standard Git command-line client behaves. When a developer runs git commit with nothing staged, Git normally refuses and prints a message such as "nothing to commit, working tree clean," returning a non-zero exit code. That guard is a safety mechanism: it prevents accidental commits and gives scripts a clear way to detect that there was nothing to record. The MCP Git server, according to the investigation, does not reproduce this guard. A commit call with an unchanged working tree returns successfully and appends a new empty commit, and repeated calls stack additional empty commits indefinitely.

The most likely explanation lies in the implementation layer. The official server is written in Python and appears to rely on a Git library rather than shelling out to the git binary. Libraries such as GitPython expose a commit operation that writes a commit object directly from the current index, and by default they do not replicate the CLI's "nothing to commit" check unless the caller explicitly compares the index against HEAD first. If the server simply forwards the agent's request to that library call, the empty-commit outcome follows naturally. This is a plausible reading of the symptoms rather than a confirmed root cause, but it is consistent with the observed lack of an error and the ease with which duplicate commits accumulate.

To put this in context, MCP is an open protocol, introduced by Anthropic, that standardizes how large language model applications connect to external tools and data sources. The ecosystem ships a collection of reference servers—covering filesystems, databases, web fetching, and Git among others—that are meant to demonstrate the protocol and provide ready-made capabilities. Because these reference servers are frequently adopted as-is inside agent frameworks, editors, and desktop clients, a defect in one of them can propagate widely. The Git server in particular is attractive for coding agents that need to inspect status, read diffs, stage files, and record commits as part of an automated workflow.

A hands-on investigation revealed that the official MCP Git server silently creates empty commits when asked to commit with no working-tree changes, stacking them indefinitely without errors.
🔗 MCP / Tooling · Key takeaway

The reliability concern becomes clearer when you consider how autonomous agents operate. An agent may loop through a plan, attempt a commit at the end of each step, and rely on the tool's response to decide what to do next. If a commit with no changes returns success instead of a "nothing to commit" signal, the agent has no way to distinguish a real commit from a no-op. Over a long-running task, or in a retry loop, this can produce a chain of meaningless empty commits that obscure the actual history, complicate code review, and interfere with tools that assume each commit represents a change. In shared repositories, such noise can also confuse continuous integration triggers and changelog generation.

Mitigations are relatively straightforward while a fix is pending. Users can check repository status before committing and skip the commit when the working tree is clean, rely on the git CLI directly for commit steps, or add validation in the agent's orchestration layer that inspects the diff before invoking the tool. Anyone maintaining a fork could add an explicit comparison between the index and HEAD, returning an informative error when nothing has changed, which would bring the server's behavior in line with the familiar command-line semantics.

More broadly, the finding is a reminder that MCP servers sit on the boundary between deterministic developer tooling and probabilistic AI behavior, where small mismatches in error handling can have outsized effects. As agent-driven development matures, careful parity with the underlying tools' safety checks is likely to matter as much as adding new capabilities, and reporting issues like this one upstream helps the reference implementations become dependable foundations rather than sources of hidden surprises.

  • 出典SourceZenn MCPコミュニティCommunity
  • 直近30件の平均重要度Avg importance, last 301=Info · 2=Medium · 3=High
  • 配信形式FormatブログBlog
  • 重要度Importance重要度 MediumMedium priority(MCP / Tooling 116件中、同等以上 116件)(116 of 116 MCP / Tooling entries are equal or higher)
  • 情報の寿命Half-life📘 中期 (チュートリアル)Medium-term (tutorial)
  • 原文言語Source languageJA
  • 収集日時Collected2026/07/20 20:34

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (zenn.dev) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (zenn.dev).

🔗MCP / Tooling の他の記事More from MCP / Toolingもっと見る →View more →