MCP Code Graph & Token Savings · 7 min read

Dead-Code & Test-Gap Detection in TypeScript, Python, Rust & Go Using MCP (dead_code & test_gaps)

Audit polyglot repositories for orphaned exports and untested modules using Memoreal MCP dead_code and test_gaps tools with automated test-coverage ratio metrics.

Direct Answer (TL;DR) Self-Contained GEO Passage

Legacy dead-code detectors and test coverage tools require heavy compilation setups, language-specific runtimes, and separate configuration files. With Memoreal's dead_code and test_gaps MCP tools, developers and AI agents audit polyglot repositories across TypeScript, Python, Rust, and Go in a single sub-15ms tool call, surfacing orphaned exports, zero-caller functions, and critical test omissions instantly.

4 Languages
Simultaneously audited in a single polyglot workspace namespace
Memoreal AST Engine Specifications
<15 ms
Query latency for dead_code symbol analysis across 250K LOC
Memoreal Benchmark Report 2026
100% AST Accuracy
Elimination of false positives from string-based grep sweeps
Comparative Code Quality Audits
Table of Contents ↓

Dead-Code & Test-Gap Auditing: Traditional Tools vs Memoreal MCP

Dead-Code & Test-Gap Auditing: Traditional Tools vs Memoreal MCP
Feature / Capabilityts-prune / ts-remove (TypeScript only)vulture (Python only)Memoreal MCP (dead_code & test_gaps)
Polyglot Monorepo SupportTypeScript onlyPython onlyTypeScript, Python, Rust, Go & 15+ languages in one pass
Agent Tool IntegrationCLI output requires parsingCLI output requires parsingNative MCP JSON-RPC tool for Claude Code & Cursor
Test-Gap CorrelationNoneNoneDirectly cross-references test files and computes coverage ratio
Entrypoint AwarenessRequires manual config regexRequires whitelist filesAccepts dynamic entrypoints parameter per audit run

The Hidden Toll of Orphaned Code and Untested Modules

As software repositories evolve, deprecated helper functions, obsolete types, and orphaned internal endpoints accumulate across codebase directories. In large polyglot applications, engineering teams rarely dedicate sprints to manual code pruning because tracing every export manually across thousands of files is exhausting.

Compounding this technical debt, new features are frequently deployed without adequate unit or integration test coverage. When AI coding agents refactor these modules, the lack of test coverage prevents automated validation, turning minor updates into high-risk engineering operations.

  • Orphaned code bloats repository size, slows build times, and confuses human and AI contributors.
  • Language-specific dead-code CLI tools do not scale across polyglot microservice architectures.
  • Missing test references prevent AI agents from verifying refactored functionality automatically.

How dead_code Identifies Zero-Caller Symbols

Memoreal evaluates dead code through comprehensive AST call-graph reachability. When the dead_code tool is called, the engine traverses symbol reference graphs starting from designated entrypoints (such as server bootstrap files or worker entrypoints).

Any symbol that has zero incoming callers outside its own file definition is flagged as an orphan candidate. The tool returns the symbol name, declaration file, line range, and symbol kind (function, class, interface, or constant), giving developers and AI agents clear targets for safe removal.

Uncovering Testing Blind Spots with test_gaps

Complementing dead-code analysis, the test_gaps tool scans workspace source files and cross-references them against test directory conventions and symbol test links. It identifies source files that lack corresponding test suites, as well as individual public functions that have zero test callers.

By running test_gaps during sprint audits or agent-driven QA workflows, teams can automatically prompt AI assistants to generate targeted unit test suites for untested business logic, systematically driving up codebase test coverage.

Auditing Orphaned Symbols and Untested Files via MCP

json
{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "dead_code",
    "arguments": {
      "namespace": "core-backend",
      "entrypoints": ["src/index.ts", "src/workers/queue.ts"]
    }
  }
}

Frequently Asked Questions

Can I exclude legitimate API entrypoints or public exports from dead_code?

Yes. You can pass an optional entrypoints array specifying routes, handlers, or public library exports that should be excluded from pruning.

Does test_gaps run my actual unit tests to measure line coverage?

No. test_gaps performs fast AST structural analysis to determine which files and functions lack test references, completing in under 15ms without running test runners.

Can Claude Code run dead_code and automatically delete orphaned files?

Yes. You can prompt Claude Code to inspect dead_code output, verify zero callers via find_references, and safely remove obsolete functions.

60-Second Setup

Install Persistent Memory for Your Coding Agent

Sub-15ms deterministic recall, AST symbol navigation, and 70%+ token savings across Claude Code, Cursor, Codex CLI, and Windsurf.

npx -y @kolivri/memoreal-mcp setup
Start Free (1,000 Calls · $0 LLM Tax) Compare All Alternatives →