Skip to main content
Glama

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.

npm version npm downloads License: ISC TypeScript MCP


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

register_rules

Writes hygiene rules into AGENTS.md / CLAUDE.md so the agent re-enforces them every session

scan_dead_code

Finds unused imports, unused variables, and exported functions with no cross-file references

scan_complexity

Flags long functions, deep nesting, large files, and duplicate code blocks

cleanse

Safely auto-removes dead imports and side-effect-free variables; flags riskier items for manual review

report

Token-efficient summary of all findings with prioritised action items

Design principles

  • Token-efficient — compact output, no JSON blobs, grouped by file

  • Safecleanse never removes code with potential side effects; it skips functions and anything with call expressions in initialisers

  • Non-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: loctree-mcp

Installation

Via npx (no install needed)

npx clenzer

Global install

npm install -g clenzer

Local project install

npm install --save-dev clenzer

Adding 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.

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 code

Tool reference

register_rules

project_root: string   # absolute path to project root

Appends 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, tests

Reports 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-function

  • Nesting depth > 4 → deep-nesting

  • File size > 600 lines → large-file

  • Duplicate block ≥ 6 lines → duplicate-block

cleanse

project_root: string    # required
dry_run?: boolean       # default: false

Auto-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 category

Returns 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:

  1. No unused imports — every import must be referenced in the file body

  2. No unused variables — variables must be read, not just declared

  3. Max function length: 60 lines — extract helpers if exceeded

  4. Max nesting depth: 4 — flatten with early returns

  5. Max file size: 600 lines — split large files into modules

  6. No duplicate code blocks — extract shared logic into utilities

  7. 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 interfaces

Tech stack

  • @modelcontextprotocol/sdk — MCP server transport and tool registration

  • ts-morph — TypeScript AST analysis and safe code modification

  • zod — 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 tools
cleanseA

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
project_rootYesAbsolute path to the project root directory
dry_runNoIf true, shows what would be removed without modifying files.

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully discloses behavior: it auto-removes unused imports and side-effect-free variables, and skips functions, exports, and initializers with side effects. It also mentions the dry_run parameter for preview. This provides a clear understanding of what the tool does and does not modify.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three concise sentences. The first sentence states the core functionality, the second provides specifics on what is removed and skipped, and the third gives a prerequisite. Every sentence is meaningful and contributes to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and annotations, the description is reasonably complete. It covers the tool's purpose, precondition (run scan_dead_code first), safe removal behavior, and dry_run option. It does not explain return values or success confirmation, but for a cleanup tool, the behavior is well-specified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already describes both parameters adequately. The description adds no further parameter-level details beyond what is in the schema, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'removes dead code' and the resource (dead code found by scan_dead_code). It implicitly distinguishes from the sibling 'scan_dead_code' by specifying that this tool cleanses while the other scans.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'Always run `scan_dead_code` first.' It also indicates what the tool skips (risky elements), helping the agent decide when to use it. However, it does not explicitly state when not to use it or list alternatives beyond the prerequisite.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
project_rootYesAbsolute path to the project root directory

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully bears the burden of disclosure. It clearly states the tool appends to a file (mutation), implying a persistent effect. It does not cover error conditions or permissions, but the core behavior is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, each earning its place: the first explains what and where, the second gives usage timing. No fluff, front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-param setup tool, the description is sufficient: it explains purpose, target file, and when to run. It does not describe return value (acceptable without output schema) or error handling, but the core completeness is high.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear description for 'project_root'. The tool description adds no new parameter info beyond the schema; it only restates 'project root' in context. Slight value from connecting parameter to file location, but baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (appends rules), target (AGENTS.md or CLAUDE.md in project root), and purpose (enforce rules every session). It distinguishes from siblings like cleanse or scan, which are different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Run this once when adding clenzer to a project,' providing a clear when-to-use context. However, it does not explicitly state when not to use or mention alternatives among siblings, though the unique setup role makes it obvious.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

reportA

Returns a compact, token-efficient summary of all findings from the last scan. Includes dead code count, complexity hotspots, and actionable next steps.

ParametersJSON Schema
NameRequiredDescriptionDefault
project_rootYesAbsolute path to the project root directory
top_nNoHow many top issues to surface per category (default: 5)

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully convey behavioral traits. It mentions 'compact, token-efficient' (performance) and lists content, but fails to disclose whether the tool is read-only (likely), requires any authentication, or has side effects. The description lacks key transparency for a safe inference.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core action ('Returns a compact summary'), then specifics. Every word adds value with no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple summarization tool with no output schema, the description adequately covers the main purpose and contents. However, it assumes a 'last scan' exists without mentioning preconditions or how multiple scans are handled, slightly reducing completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters (project_root, top_n). The description adds no additional meaning beyond what the schema provides, meeting the baseline for high coverage but not exceeding it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns a compact summary of findings from the last scan, listing specific contents like dead code count, complexity hotspots, and actionable next steps. This distinguishes it from siblings like scan_dead_code and scan_complexity, which perform individual scans rather than summarize.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool should be used after a scan has been run ('from the last scan'), but does not explicitly state when to use it versus alternatives, nor does it provide when-not guidance. With siblings including multiple scanning tools, it could be clearer which scan results are aggregated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

scan_complexityC

Scans for unnecessary complexity: overly long functions, deep nesting, large files, and duplicate code blocks.

ParametersJSON Schema
NameRequiredDescriptionDefault
project_rootYesAbsolute path to the project root directory
includeNo
excludeNo

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must disclose behavioral traits. It does not mention whether the tool is read-only, destructive, or what side effects occur. The scan likely is non-destructive but never stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence front-loaded with purpose, no wasted words. However, it sacrifices parameter and usage detail, which is acceptable for conciseness but impacts completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 3 parameters and no output schema, description is incomplete. It does not explain return values, how to interpret results, or how exclude/include interact. For a scanning tool, this is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 33% (only project_root described). Tool description adds no detail about include/exclude parameters or how they filter the scan. The description does not compensate for low schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Scans for unnecessary complexity' and lists specific types (overly long functions, deep nesting, large files, duplicate code blocks). This verb+resource is distinct from sibling tools like scan_dead_code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives, no prerequisites, and no context on expected input or output format. The description simply states what it does.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
project_rootYesAbsolute path to the project root directory
includeNoGlob patterns to include, e.g. ['src/**/*.ts']. Defaults to all TS/JS files.
excludeNoGlob patterns to exclude, e.g. ['**/*.test.ts', 'node_modules/**']

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description discloses that results are stored in session state—a key behavioral trait. It outlines the scanning scope but omits potential limitations like performance or handling of JavaScript files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no wasted words. Front-loaded with the primary function, then storage detail. Highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 params, no output schema, and no annotations, the description covers purpose, stored results, and sibling linkage. Missing guidance on interpreting results beyond use by `cleanse`, but adequate overall.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (all params described). The description adds the default for `include` (all TS/JS files) not present in the schema, enhancing understanding beyond the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description specifies the tool scans TypeScript/JavaScript projects for dead code types (unused imports, variables, exported functions), distinguishing it from siblings like scan_complexity. The verb 'scans' and resource 'dead code' are clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description states results are stored for use by `cleanse`, implying a preparatory context. It doesn't explicitly state when-not-to-use or alternatives, but the sibling context (e.g., scan_complexity) provides differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv1.0.0
    • First observedcleanse
    • First observedregister_rules
    • First observedreport
    • First observedscan_complexity
    • First observedscan_dead_code

TDQS

A3.9/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: scanning for dead code, cleaning dead code, scanning for complexity, reporting, and registering rules. No overlap.

Naming Consistency5/5

All tool names use lowercase with underscores and follow a verb_noun pattern or single verb (cleanse, report). Consistent and predictable.

Tool Count5/5

Five tools is well-scoped for a code hygiene assistant, covering scanning, cleaning, reporting, and setup without excess.

Completeness4/5

Covers dead code detection and removal, complexity scanning, and reporting. Minor gap: no automatic fix for complexity issues (only scan).

Maintenance

ActivityStale
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    A
    maintenance
    Structural code intelligence for AI agents. Scan once, query everything — dead exports, circular imports, dependency graphs, and more. CLI + MCP server.
    6
    9
    -
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.
    29
    342
    3
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to analyze code health in TypeScript/JavaScript projects, providing tools to run analysis, start a dashboard, and get summaries.
    22
    3
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Parth3930/clenzer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server