analyze_dead_code
Analyze a completed scan to identify dead JavaScript functions.
Reads V8 coverage data collected during the scan, merges execution counts across passes, and reports every function with zero executions.
Explores a running site with a browser agent, records V8 coverage, and writes patches that delete the JavaScript nothing executed.
LABSCO SUMMARY
The evidence for removing a function is that it never ran while a browser agent used the site, and risk scores plus pre-patch snapshots mean a wrong call is reversible. Coverage only proves what the crawl exercised, which is what the verification replay is for.
An MCP server for Cursor that finds dead JavaScript by driving a real browser over your site, collecting V8 precise coverage, and turning zero-execution functions into removal patches.
Python 3.11+, Playwright Chromium installed with playwright install chromium, and a Gemini API key, which the first run writes into ~/.cursor/mcp.json.
One command plus a key — pipx run codereaper, then supply credentials
USE CASES
Point it at the site and read back the dead functions with file paths and line numbers.
Generate the diff, read it, then apply it to the source files.
Replay the original interactions after the patch, and restore the files if something regressed.
Reuse the scan instead of crawling again, and regenerate patches from it.
Start the crawl on its own and check its status while it runs.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
analyze_dead_codeAnalyze a completed scan to identify dead JavaScript functions.
Reads V8 coverage data collected during the scan, merges execution counts across passes, and reports every function with zero executions.
apply_patchApply a generated patch to the source files on disk.
Stores pre-patch snapshots so the change can be rolled back later. Review the diff (get_patch_diff) before applying.
find_dead_codeScan a website and find dead JavaScript code using an AI browser agent.
This is the primary tool. It launches a Chromium browser with an AI agent that autonomously explores the site (clicks buttons, navigates routes, opens modals, fills forms, triggers keyboard shortcuts) while V8 precise coverage tracks which JavaScript functions actually execute.
Functions that receive zero executions across all exploration passes are reported as dead-code candidates with risk scores and removal recommendations.
generate_patchesGenerate unified-diff patches that remove dead code.
Creates a patch set based on the analysis results for the given scan. Each affected file gets a unified diff that replaces dead functions with a removal comment.
get_patch_diffRetrieve the combined unified diff for a generated patch.
get_scan_statusGet detailed status and metadata for a specific scan.
list_scansList recent scans with their status.
Returns: JSON array of scan records (most recent first, up to 20).
rollback_patchRollback a previously applied patch, restoring the original files.
scan_websiteLaunch the AI browser agent to explore a website and collect V8 coverage.
Use this when you want to run the scan separately from the analysis (e.g. to inspect scan status first). After it completes, pass the returned scan_id to analyze_dead_code().
verify_patchVerify an applied patch by replaying the original interactions.
Re-runs the browser agent with the same interaction plan used during the scan and checks for regressions: new console errors, missing elements, and coverage drops.
BEFORE YOU INSTALL
10 tools when we connected.
CONTEXT COST
Rated by the size of the 10 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
pip install codereaper
playwright install chromiumRun codereaper once: it asks for your Gemini API key and adds itself, with that key, to your global ~/.cursor/mcp.json
Restart Cursor
You do not set GEMINI_API_KEY by hand: the first time you run codereaper it asks for your Gemini key and saves it in your global ~/.cursor/mcp.json, which is where Cursor passes it to the server from.
pipx run codereaperYou do not set GEMINI_API_KEY by hand: the first time you run codereaper it asks for your Gemini key and saves it in your global ~/.cursor/mcp.json, which is where Cursor passes it to the server from.