
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 分