clenzer
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@clenzer scan for dead code in my project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
clenzer
MCP server that hunts dead code and complexity — then cleanses it.
Add it to any CLI agent and your codebase stays lean on every session.
What it does
clenzer is a Model Context Protocol (MCP) server that plugs into any MCP-compatible CLI agent (Claude Code, Antigravity, Cursor, etc.) and gives it five new tools:
Tool | Description |
| Writes hygiene rules into |
| Finds unused imports, unused variables, and exported functions with no cross-file references |
| Flags long functions, deep nesting, large files, and duplicate code blocks |
| Safely auto-removes dead imports and side-effect-free variables; flags riskier items for manual review |
| Token-efficient summary of all findings with prioritised action items |
Design principles
Token-efficient — compact output, no JSON blobs, grouped by file
Safe —
cleansenever removes code with potential side effects; it skips functions and anything with call expressions in initialisersNon-destructive — dry-run mode available; skipped items are always explained
Zero config — works on any TS/JS project with or without
tsconfig.json
Related MCP server: ts-language-mcp
Installation
Via npx (no install needed)
npx clenzerGlobal install
npm install -g clenzerLocal project install
npm install --save-dev clenzerAdding to your CLI agent
Claude Code / Antigravity CLI
Add to your mcp_config.json (usually ~/.gemini/antigravity/mcp_config.json or ~/.claude/mcp_config.json):
{
"mcpServers": {
"clenzer": {
"command": "npx",
"args": ["-y", "clenzer"],
"env": {}
}
}
}Or if installed globally:
{
"mcpServers": {
"clenzer": {
"command": "clenzer",
"args": [],
"env": {}
}
}
}Cursor / other MCP hosts
Add the same block to your MCP host's server config. Refer to your host's documentation for the exact file location.
Usage
Once clenzer is connected to your agent, use natural language or call the tools directly.
Recommended workflow
1. register_rules — run once per project to lock in hygiene rules
2. scan_dead_code — before any significant editing session
3. scan_complexity — identify hotspots
4. report — get a prioritised action list
5. cleanse — auto-remove safe dead codeTool reference
register_rules
project_root: string # absolute path to project rootAppends clenzer's hygiene rules to AGENTS.md (or CLAUDE.md if it exists). The agent will re-read this file every session, ensuring the rules are always active.
scan_dead_code
project_root: string # required
include?: string[] # glob patterns, default: all TS/JS files
exclude?: string[] # glob patterns, default: node_modules, dist, testsReports unused imports, unused variables, and exported functions with no cross-file references. Results are stored in session state for use by cleanse.
scan_complexity
project_root: string # required
include?: string[]
exclude?: string[]Thresholds (all configurable via future config file):
Function length > 60 lines →
long-functionNesting depth > 4 →
deep-nestingFile size > 600 lines →
large-fileDuplicate block ≥ 6 lines →
duplicate-block
cleanse
project_root: string # required
dry_run?: boolean # default: falseAuto-removes items safe to delete (unused imports, variables with no side effects). Skips functions, exports, and anything with call expressions in the initialiser — those are flagged for manual review.
report
project_root: string # required
top_n?: number # default: 5 — how many issues to surface per categoryReturns a compact markdown summary with dead code counts by kind, high-severity complexity hotspots, and recommended next steps.
Hygiene rules enforced
When you run register_rules, the following are appended to your AGENTS.md:
No unused imports — every import must be referenced in the file body
No unused variables — variables must be read, not just declared
Max function length: 60 lines — extract helpers if exceeded
Max nesting depth: 4 — flatten with early returns
Max file size: 600 lines — split large files into modules
No duplicate code blocks — extract shared logic into utilities
Prefix intentionally unused variables with
_— clenzer skips them
Development
git clone https://github.com/Parth3930/clenzer.git
cd clenzer
npm install
npm run build # compile TypeScript → dist/
npm run dev # run with tsx (no compile step)Project structure
src/
├── index.ts # MCP server, all 5 tools
├── scanner.ts # AST-based dead code + complexity analysis (ts-morph)
├── cleanser.ts # Safe removal engine
├── rules.ts # AGENTS.md / CLAUDE.md rule injection
└── types.ts # Shared interfacesTech stack
@modelcontextprotocol/sdk— MCP server transport and tool registrationts-morph— TypeScript AST analysis and safe code modificationzod— Runtime schema validation for tool inputs
Keywords
mcp, mcp-server, dead-code, unused-imports, code-cleanup, refactor, typescript, javascript, code-quality, static-analysis, ast, ts-morph, claude-code, cursor, antigravity, model-context-protocol, linter, cleaner, unused-variables, complexity
License
ISC © Parth3930
Available Tools
5 toolscleanseA
Safely removes dead code found by scan_dead_code. Auto-removes unused imports and side-effect-free variables. Skips anything risky (functions, exports, initializers with side effects). Always run scan_dead_code first.
Inputs: project_root (required), dry_run.
register_rulesA
Appends clenzer hygiene rules to AGENTS.md (or CLAUDE.md) in the project root so the agent enforces them every session. Run this once when adding clenzer to a project.
Inputs: project_root (required).
reportA
Returns a compact, token-efficient summary of all findings from the last scan. Includes dead code count, complexity hotspots, and actionable next steps.
Inputs: project_root (required), top_n.
scan_complexityC
Scans for unnecessary complexity: overly long functions, deep nesting, large files, and duplicate code blocks.
Inputs: project_root (required), include, exclude.
scan_dead_codeA
Scans a TypeScript/JavaScript project for dead code: unused imports, unused variables, and exported functions with no cross-file references. Results are stored in session state for use by cleanse.
Inputs: project_root (required), include, exclude.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: scanning for dead code, cleaning dead code, scanning for complexity, reporting, and registering rules. No overlap.
All tool names use lowercase with underscores and follow a verb_noun pattern or single verb (cleanse, report). Consistent and predictable.
Five tools is well-scoped for a code hygiene assistant, covering scanning, cleaning, reporting, and setup without excess.
Covers dead code detection and removal, complexity scanning, and reporting. Minor gap: no automatic fix for complexity issues (only scan).
Maintenance
Related MCP Connectors
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides AI agents with powerful JavaScript/TypeScript code analysis and transformation capabilities using the tree-hugger-js library.1237 npm2MIT
- AlicenseAqualityBmaintenanceEnables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.29194 npm4Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze code health in TypeScript/JavaScript projects, providing tools to run analysis, start a dashboard, and get summaries.8 npm3MIT
- AlicenseAqualityDmaintenanceProvides deep structural analysis of TypeScript and JavaScript code via the TypeScript Compiler API, offering 20 tools for functions, types, call graphs, code quality, dead code detection, and IDE integration.20108 npmMIT