- 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.
- See also: Compression Tier, Benchmarks
- 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, andinjector_statsas callable tools. - See also: MCP Tools documentation
- 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.
- See also: KV Prompt Cache
- 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.
- See also: Canonical Determinism, vs Repomix
- Compression Tier #compression-tier
-
mcp-injector's three-level compression system passed as the
tierparameter toget_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.
unfolded_filesparameter. - See also: AST Body Folding, get_project_map
- CCR (Compress-Cache-Retrieve) #ccr
-
The three-phase context delivery pattern used by mcp-injector for maximum efficiency:
- Compress — Claude calls
get_project_mapto receive the entire codebase as compressed signatures. - Cache — The compressed output is cached by Anthropic's KV prompt cache. Subsequent sessions reuse this cache.
- Retrieve — Claude calls
injector_retrieveonly for specific files it needs to inspect at full resolution, avoiding full-context re-delivery.
- Compress — Claude calls
- See also: KV Prompt Cache, MCP Tools
- 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.
- See also: Security documentation
// 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 { ... }