safe-fix-mcp
safe-fix-mcp
Python 저장소에서 데드 코드를 찾고, 실제로 안전하게 자동 제거할 수 있는 한 가지 유형(단일 이름 가져오기 줄의 사용되지 않는 import)에 대해 브랜치 + PR을 제안하는 실제 MCP 서버입니다. 그 외에 찾은 것들(사용되지 않는 함수, 클래스, 사용되지 않는 의존성)은 보고만 합니다. 병합은 항상 사람이 합니다. 이 도구는 스스로 아무것도 병합하지 않습니다.
왜 이게 필요한가
대부분의 "데드 코드" 도구는 보고에서 멈춥니다. 더 나아가는 도구들도 대개 안전장치 없이 삭제합니다. 이 도구는 둘 다 아닙니다: 제거 후 대상 저장소의 전체 테스트 스위트가 실제로 통과하는지 확인한 뒤에만, 실제적이고 최소한의 검토 가능한 PR을 초안으로 작성합니다. 휴리스틱이 아니라 실제 pytest 실행입니다. 스위트가 실패하면 아무것도 커밋하거나 푸시하지 않으며, 저장소는 처음과 똑같이 남습니다.
Related MCP server: Python Code Guardian MCP Server
도구
scan_dead_code(repo_path=".", min_confidence=60)
읽기 전용입니다. vulture(데드 코드)와 deptry(의존성 문제)를 실행하고 사람이 읽을 수 있는 결과 목록을 반환합니다. 아무것도 수정하지 않습니다.
propose_removal_pr(repo_path=".")
작업 트리가 더티하면 거부합니다. 커밋되지 않은 작업 위에서 절대 편집하지 않습니다.
단일 이름 가져오기 줄에서만 vulture 신뢰도 ≥90%인 사용되지 않는 import로 필터링합니다(
from x import y, z는 건너뜁니다. 전체 줄을 제거하면z도 조용히 제거되기 때문입니다).실제 브랜치를 만들고, 해당하는 import를 제거하고, 저장소의 실제 전체 테스트 스위트를 실행합니다.
실제 통과 시에만: 커밋, 푸시,
gh pr create로 PR 열기를 시도합니다.gh가 설치/인증되지 않은 경우에도 브랜치는 실제로 커밋되고 푸시됩니다. PR 생성만 실패하며, 실제 오류가 반환되므로 수동으로 열 수 있습니다.
설치
pip install -e .MCP 클라이언트 구성에 추가합니다(예: Claude Code):
claude mcp add safe-fix-mcp -- safe-fix-mcp또는 로컬 테스트를 위해 직접 실행:
python -m safe_fix_mcp.server요구 사항
Python ≥ 3.10
PATH에
gitpropose_removal_pr가 실제로 PR을 열려면 PATH에gh(GitHub CLI)가 설치·인증되어 있어야 합니다. 없어도 브랜치는 실제로 푸시되며, 도구가 수동으로 PR을 열라고 안내합니다.
개발
pip install -e ".[dev]"
pytest알려진 제한 사항
vulture는 scan_dead_code/propose_removal_pr 자체를 "사용되지 않음"으로 표시합니다. 알려진 오탐 클래스이지 실제 버그가 아닙니다. 이들은 런타임에 @mcp.tool() 데코레이터로 디스패치되며 소스 어디에서도 직접 호출되지 않으므로 정적 호출 그래프 분석으로는 실제 호출자(MCP 프레임워크 자체)를 볼 수 없습니다.
실제 검증
scripts/verify_real_client.py는 패키징된 서버를 실제 하위 프로세스로 실행하고 실제 mcp.client.ClientSession으로 통신합니다. 실제 MCP 클라이언트가 사용하는 것과 동일한 경로입니다. 변경 후 스모크 테스트로 유용합니다:
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-