
Safe Fix Mcp
io.github.pamela-0由 GitHub 账号 pamela-0 发布v0.1.1更新于 Oct 24, 2026
Finds real dead code and proposes a safe, test-gated branch+PR to remove it.
概览
在 Python 仓库中查找死代码,并提议一个经测试把关的分支与拉取请求来移除未使用的导入。
- 可以做什么
- scan_dead_code 运行 vulture 和 deptry,以只读方式返回未使用的导入、函数、类与依赖等发现列表。propose_removal_pr 只筛选置信度不低于 90% 且位于单名称导入行上的未使用导入,创建分支、移除这些导入,并运行仓库的完整测试套件。只有测试真正通过时,它才会提交、推送并尝试用 gh pr create 创建拉取请求。其他发现仅作报告,且该工具从不合并。
- 适用场景
- 当你维护一个带有真实测试套件的 Python 仓库,并希望把死代码发现转化为最小、可审查的拉取请求而不是手工清理时使用。它适合希望自动移除仅限最安全情形(未使用的单名称导入)、而把风险更高的发现保留为报告的场景。它不适用于没有测试的仓库,也不用于自动合并。
- 运行要求
- 本地 Python 包(pip install safe-fix-mcp),需要 Python 3.10 或更高版本,以及 PATH 中的 git。若要让 propose_removal_pr 真正创建拉取请求,需要安装并认证 gh(GitHub CLI);没有它分支仍会被推送,需手动创建 PR。未声明任何 API 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 Safe Fix Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
safe-fix-mcp
A real MCP server that finds dead code in a Python repository and proposes a branch + PR for the one class of finding that's actually safe to auto-remove: unused imports on a single-name import line. Everything else it finds — unused functions, classes, unused dependencies — stays report-only. A human always merges. This tool never merges anything itself.
Why this exists
Most "dead code" tools stop at reporting. The ones that go further usually delete with no safety net. This does neither: it drafts a real, minimal, reviewable PR, gated on the target repo's own full test suite actually passing after the removal — not a heuristic, a real pytest run. If the suite fails, nothing is committed or pushed; the repo is left exactly as it started.
Tools
scan_dead_code(repo_path=".", min_confidence=60)
Read-only. Runs vulture (dead code) and deptry (dependency issues) and returns a human-readable list of findings. Never modifies anything.
propose_removal_pr(repo_path=".")
- Refuses on a dirty working tree — never edits on top of uncommitted work.
- Filters to unused imports at ≥90% vulture confidence, on single-name import lines only (
from x import y, zis skipped — removing the whole line would silently removeztoo). - Creates a real branch, removes the qualifying imports, runs the repo's real full test suite.
- Only on a real pass: commits, pushes, and tries to open a PR via
gh pr create. - If
ghisn't installed/authenticated, the branch is still committed and pushed for real — only PR creation degrades, with the real error returned so you can open it manually.
Install
Add to your MCP client config (e.g. Claude Code):
Or run directly for local testing:
Installing from source instead of PyPI:
Skill
A SKILL.md ships inside this same package — not a separate download — and teaches Claude when and how to use the two tools correctly (e.g. that propose_removal_pr only ever auto-removes single-name unused imports, never functions/classes/dependencies). Install it into your project:
Run it from the project root you want the skill active in — it writes to .claude/skills/safe-fix-mcp/SKILL.md relative to your current directory.
Requirements
- Python ≥ 3.10
giton PATHgh(GitHub CLI) on PATH and authenticated, if you wantpropose_removal_prto actually open the PR — without it, the branch still gets pushed for real, and the tool tells you to open the PR by hand.
Development
Known limitation
vulture flags scan_dead_code/propose_removal_pr themselves as "unused" — a known false-positive class, not a real bug: they're dispatched by the @mcp.tool() decorator at runtime, not called directly anywhere in the source, so static call-graph analysis can't see the real caller (the MCP framework itself).
Verifying it for real
scripts/verify_real_client.py launches the packaged server as a real subprocess and talks to it with the real mcp.client.ClientSession — the same path a real MCP client uses. Useful as a smoke test after any change:
来源:README.md,提交 b9309a1
工具
0版本历史
1- v0.1.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分