safe-fix-mcp
safe-fix-mcp
Ein echter MCP-Server, der toten Code in einem Python-Repository findet und einen Branch + PR für die eine Klasse von Befunden vorschlägt, die tatsächlich sicher automatisch entfernt werden kann: ungenutzte Importe in einer einzelnen Importzeile. Alles andere, was er findet – ungenutzte Funktionen, Klassen, ungenutzte Abhängigkeiten – bleibt nur als Bericht. Ein Mensch führt den Merge immer durch. Dieses Tool merged niemals selbst etwas.
Warum es das gibt
Die meisten „Dead Code“-Tools hören beim Melden auf. Diejenigen, die weitergehen, löschen meist ohne Sicherheitsnetz. Dieses tut keines von beidem: Es entwirft einen echten, minimalen, überprüfbaren PR, der davon abhängt, dass die vollständige Testsuite des Ziel-Repositorys nach der Entfernung tatsächlich besteht – keine Heuristik, sondern ein echter pytest-Lauf. Wenn die Suite fehlschlägt, wird nichts committet oder gepusht; das Repository bleibt exakt so, wie es begonnen hat.
Related MCP server: Python Code Guardian MCP Server
Tools
scan_dead_code(repo_path=".", min_confidence=60)
Nur lesend. Führt vulture (toter Code) und deptry (Abhängigkeitsprobleme) aus und gibt eine menschenlesbare Liste von Befunden zurück. Ändert niemals etwas.
propose_removal_pr(repo_path=".")
Lehnt bei einem verschmutzten Arbeitsbaum ab – bearbeitet niemals über uncommittete Arbeit.
Filtert auf ungenutzte Importe mit ≥90 % vulture-Konfidenz, nur bei einzelnen Importzeilen (
from x import y, zwird übersprungen – das Entfernen der gesamten Zeile würde auchzstillschweigend entfernen).Erstellt einen echten Branch, entfernt die qualifizierenden Importe, führt die echte vollständige Testsuite des Repositorys aus.
Nur bei einem echten Erfolg: committet, pusht und versucht, einen PR via
gh pr createzu öffnen.Wenn
ghnicht installiert/authentifiziert ist, wird der Branch trotzdem echt committet und gepusht – nur die PR-Erstellung wird herabgestuft, mit dem echten Fehler als Rückgabe, damit du den PR manuell öffnen kannst.
Installation
pip install -e .Füge dies zu deiner MCP-Client-Konfiguration hinzu (z. B. Claude Code):
claude mcp add safe-fix-mcp -- safe-fix-mcpOder führe es direkt für lokale Tests aus:
python -m safe_fix_mcp.serverAnforderungen
Python ≥ 3.10
gitim PATHgh(GitHub CLI) im PATH und authentifiziert, wennpropose_removal_prtatsächlich den PR öffnen soll – ohne dies wird der Branch trotzdem echt gepusht, und das Tool sagt dir, den PR von Hand zu öffnen.
Entwicklung
pip install -e ".[dev]"
pytestBekannte Einschränkung
vulture markiert scan_dead_code/propose_removal_pr selbst als „ungenutzt“ – eine bekannte False-Positive-Klasse, kein echter Bug: Sie werden zur Laufzeit durch den @mcp.tool()-Decorator dispatched, nicht direkt irgendwo im Quellcode aufgerufen, sodass die statische Call-Graph-Analyse den echten Aufrufer (das MCP-Framework selbst) nicht sehen kann.
Echte Verifizierung
scripts/verify_real_client.py startet den gepackten Server als echten Subprozess und kommuniziert mit ihm über die echte mcp.client.ClientSession – denselben Pfad, den ein echter MCP-Client verwendet. Nützlich als Smoke-Test nach jeder Änderung:
python scripts/verify_real_client.pyAvailable Tools
2 toolspropose_removal_prA
Propose a real branch+PR removing only unused imports (single-name
import lines, >= 90% vulture confidence) from a Python repository. Runs
the repo's own full test suite as a safety gate before ever committing
or pushing — a failure there reverts everything and nothing is
committed or pushed. If gh isn't available or PR creation otherwise
fails, the branch is still committed and pushed for real; only the PR
itself needs opening manually. A human always merges — this never
merges anything itself.
repo_path: path to a real git repository with a clean working tree (uncommitted changes are refused, not overwritten).
Inputs: repo_path. Returns: result
scan_dead_codeA
Scan a Python repository for real dead code (vulture) and dependency issues (deptry). Read-only — never modifies anything. Returns a human-readable list of findings, or "No real candidates found."
repo_path: path to the repository to scan (must contain a pyproject.toml for the dependency checks to run; dead-code scanning works regardless). min_confidence: vulture's own confidence threshold (0-100). Lower values surface more candidates but more false positives.
Inputs: repo_path, min_confidence. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
scan_dead_code is purely read-only analysis, while propose_removal_pr actually creates a branch and PR. Their purposes are complementary and unlikely to be confused.
Both tool names use lower_snake verb-first conventions: scan_dead_code and propose_removal_pr. The pattern is predictable, though the second name is slightly less clean because 'removal_pr' bundles an action and an object into one noun phrase.
Two tools is on the thin side and sits at the borderline of feeling complete. However, each tool has a distinct role in a focused analyze-then-propose workflow, so the small count is plausible for a narrow server.
The scan surfaces both dead code and dependency issues, but propose_removal_pr only handles unused imports. Dependency fixes and non-import dead-code removals are therefore dead ends, creating a notable gap in the advertised safe-fix domain.
Maintenance
Related MCP Connectors
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.
Scan a public GitHub repo for known Vercel Python-runtime deploy footguns.
Security + bug + perf + refactor audit for Python. Returns 0-10 score + MD report.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables automated code review and GitHub PR commenting through MCP integration.1,175 npm9MIT
- AlicenseNot gradedqualityCmaintenanceEnables automated Python code quality checks including linting, complexity analysis, typo detection, structure validation, duplicate detection, and test coverage, with integration into Cursor IDE and CLI.MIT
- AlicenseNot gradedqualityDmaintenanceEnables scanning projects for dependency vulnerabilities, secrets, license conflicts, code quality, and git health, returning a 0-100 health score with actionable suggestions.MIT
- FlicenseNot gradedqualityBmaintenanceEnables whole-program callgraph reachability analysis to locate dead functions and stale flags, and integrates with MCP-compliant clients for automated code review, breaking-change audits, and CI/CD workflow pruning.8-