mcp-server-git: git_status and the git_diff tools print non-ASCII paths as octal escapes, so git_add cannot take them back
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 57/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- git, python
调研方向
Read src/git/src/mcp_server_git/server.py, especially the git_status and diff tool implementations around the reported line 155. Reproduce with the supplied Python script and a filename containing non-ASCII characters; the issue also points to PR #4879 and four tests as reference. Done when status and all three diff tools return paths that can be passed to git_add.
由索引模型根据 Issue 内容生成。
描述
Which server?
git (mcp-server-git)
Server version
2026.10.10, from v2/main at 2f8dc42
How did you run the server?
From a clone of this repository
Transport
stdio
Protocol era
Not sure. The repro calls the tool functions in-process, so it does not depend on the era.
MCP client and version
n/a, the tool functions were called directly from Python
Operating system and runtime
Linux, Python 3.10.21, git 2.43.0, GitPython 3.2.0
Server configuration
None beyond uv sync --frozen --dev in src/git.
Steps to reproduce
- In a fresh repository, create an untracked file named
日本.txt. - Call
git_status, strip the surrounding double quotes from the name it prints, and pass that name togit_add. - Save the script below as
repro.pyinsrc/gitand run it.
repro.py
import pathlib, subprocess, tempfile
import git
import mcp_server_git.server as s
d = pathlib.Path(tempfile.mkdtemp())
subprocess.run(["git", "init", "-q", str(d)], check=True)
r = git.Repo(d)
(d / "日本.txt").write_text("a\n")
print("--- git_status")
st = s.git_status(r)
print("\n".join(l for l in st.splitlines() if "Untracked" in l or ".txt" in l))
name = [l.strip() for l in st.splitlines() if ".txt" in l][0].strip('"')
r.git.add("日本.txt")
print("--- git_diff_staged (headers)")
print("\n".join(l for l in s.git_diff_staged(r).splitlines() if l.startswith("diff --git")))
r.git.rm("--cached", "-q", "日本.txt")
print("--- git_add with the name git_status printed")
try:
s.git_add(r, [name])
except Exception as e:
print(type(e).__name__ + ":", str(e).split("stderr: ")[-1].strip().strip("'"))
print("--- the same status with -c core.quotepath=false")
print("\n".join(l.strip() for l in r.git(c="core.quotepath=false").status().splitlines() if ".txt" in l))
$ uv run python repro.py # src/git at 2f8dc42
--- git_status
Untracked files:
"\346\227\245\346\234\254.txt"
--- git_diff_staged (headers)
diff --git "a/\346\227\245\346\234\254.txt" "b/\346\227\245\346\234\254.txt"
--- git_add with the name git_status printed
GitCommandError: fatal: pathspec '\346\227\245\346\234\254.txt' did not match any files
--- the same status with -c core.quotepath=false
日本.txt
Expected behavior
git_status and the three diff tools print 日本.txt, a name a client can pass back to git_add.
Actual behavior
src/git/src/mcp_server_git/server.py:155 calls repo.git.status() with git's default core.quotepath=true, so every non-ASCII path comes back as quoted octal escapes. git_diff_unstaged, git_diff_staged and git_diff do the same.
Already prototyped a fix?
#4879 by @tsurutanmen has the change and four tests for it, written against main. It runs the four commands with -c core.quotepath=false.
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory form).
@cliffhall could this go on the board for the git server?
- 主要语言
- TypeScript
- 星标
- 91.6k
- 派生
- 11.9k
- 平均合并
- 5 小时 18 分钟
- 30 天内合并 PR
- 185
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/servers 的其他 Issue
-
filesystem: bounded-walk 100000-entry test times out on slow Windows runners (vitest's 5 s default)未关闭bug server-filesystem v2
难度 1/5 1 小时以内 新手友好度 88/100
modelcontextprotocol/servers#5328 · 1 条评论 ·
维护者通常 1 天内回复
-
bug server-filesystem v2
难度 2/5 1-3 小时 新手友好度 83/100
modelcontextprotocol/servers#5314 ·
维护者通常 1 天内回复
-
docs(git): clarify unconfined default scope and repository confinement options in README and CLI未关闭
难度 2/5 1-3 小时 新手友好度 73/100
modelcontextprotocol/servers#5231 · 1 条评论 ·
维护者通常 1 天内回复
-
docs(git): clarify unconfined default scope and repository confinement options in README and CLI未关闭
难度 1/5 1 小时以内 新手友好度 74/100
modelcontextprotocol/servers#5230 ·
维护者通常 1 天内回复
-
bug v2
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/servers#5217 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/servers 的全部 Issue
相似的 Issue
-
[Bug]: Payment providers removed from config are never disabled in payment_provider可能已有人在做 @medusa-os-bot 今天认领。 未关闭type: bug
难度 2/5 半天 新手友好度 82/100
medusajs/medusa#17544 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
software-mansion/argent#1651 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
lane:reliability
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复