AST Body Folding #ast-body-folding
A compression technique where function, method, and class bodies in source code are replaced with stub markers while keeping signatures, type definitions, and interface declarations intact. The result is a skeleton view of the entire codebase that conveys full architectural understanding at a fraction of the original token count — typically 57–89% fewer tokens than the raw source.
// Before (full source — 12 tokens in body)
func ProcessPayment(amount float64, userID string) error {
    user, err := db.GetUser(userID)
    if err != nil { return err }
    return stripe.Charge(user.Card, amount)
}

// After AST body folding (body → stub)
func ProcessPayment(amount float64, userID string) error { ... }
Model Context Protocol (MCP) #mcp
An open standard developed by Anthropic that defines how AI assistants can interact with external tools, data sources, and services during a conversation. An MCP server exposes named tools that the AI can call. mcp-injector runs as a local MCP server, exposing get_project_map, injector_retrieve, and injector_stats as callable tools.
Canonical Determinism #canonical-determinism
The property of producing byte-identical output on every run given the same input. mcp-injector achieves this by sorting files alphabetically, stripping volatile metadata (timestamps, PIDs), and applying a fixed compression pipeline. Canonical determinism is essential for maximising Anthropic KV prompt cache hit rates — if the prompt prefix is not identical byte-for-byte, the cache misses and full input token costs apply.
KV Prompt Cache #kv-prompt-cache
A server-side caching mechanism in Anthropic's Claude API. When the same token sequence appears at the start of a prompt, Anthropic reuses the previously computed key-value attention states instead of recomputing them from scratch. This reduces effective input token costs by 40–90% on cache hits. Because mcp-injector produces byte-identical output, the first session pays full price and every subsequent session on the same codebase hits the cache.
Compression Tier #compression-tier
mcp-injector's three-level compression system passed as the tier parameter to get_project_map:
  • Tier 1 — No compression. Raw file content served as-is.
  • Tier 2 — AST body folding only. Function bodies replaced with stubs; comments preserved.
  • Tier 3 (default) — AST body folding plus comment stripping. Maximum token reduction.
Individual files can bypass compression entirely using the unfolded_files parameter.
CCR (Compress-Cache-Retrieve) #ccr
The three-phase context delivery pattern used by mcp-injector for maximum efficiency:
  1. Compress — Claude calls get_project_map to receive the entire codebase as compressed signatures.
  2. Cache — The compressed output is cached by Anthropic's KV prompt cache. Subsequent sessions reuse this cache.
  3. Retrieve — Claude calls injector_retrieve only for specific files it needs to inspect at full resolution, avoiding full-context re-delivery.
Shannon Entropy #shannon-entropy
A mathematical measure of information density in a string, measured in bits per character. A string where each character is equally probable has maximum entropy (~6 bits/char for alphanumeric). Normal English text has ~4 bits/char. High-entropy strings above 4.5 bits/char are statistically unlikely to be human-readable and are often randomly generated secrets such as API keys, bearer tokens, or passwords. mcp-injector uses Shannon entropy analysis alongside 11 regex patterns to detect and redact credentials before they reach Claude's context window.