Hi everyone,
When building or using AI coding agents on medium-to-large codebases, a common architectural bottleneck is context management:
- Context Window Bloat: Feeding entire raw source files quickly inflates prompt tokens, drives up API latency/costs, and dilutes attention.
- Phantom API Hallucinations: Models occasionally hallucinate methods or library imports that don’t exist in the actual repository.
- Secret Leaks: Raw credentials and environment tokens can accidentally slip into outbound LLM context windows.
To address this deterministically, I developed T-Zero, an open-source, local-first Model Context Protocol (MCP) server designed for context compression and reality verification.
Architectural Mechanism:
- Deterministic AST Pruning: Instead of ingesting full function implementations, T-Zero parses multi-language codebases (Python, TypeScript, Rust, Go) into typed AST interface skeletons. Internal function bodies are replaced with
..., while preserving 100% of classes, method signatures, parameter types, decorators, and docstrings. This achieves an 85–95% reduction in context token consumption while keeping full architectural awareness for the LLM. - Pre-Flight Reality-Lock: Before code generation, the agent validates imported symbols and method calls against the codebase’s real AST, eliminating fake API hallucinations.
- Local Shannon Entropy Scanner: Outbound context is locally inspected with a mathematical Shannon entropy scanner ($H \ge 4.75$) to intercept raw API keys, JWTs, and cloud credentials before transmission.
Technical Implementation:
- Dual-Engine Core: Hybrid architecture utilizing a native Rust core (
crates/tzero_corewith Tree-sitter andtiktoken-rsoperating at >940k tokens/sec) with a zero-fail pure-Python fallback. - Privacy & Local-First: Runs 100% locally with zero external API dependencies and zero telemetry.
- Test Coverage: Verified with 630+ unit/integration tests running across multi-platform CI matrices (Ubuntu, macOS, Windows).
How to Test via MCP:
You can run the MCP server directly in any MCP-compatible environment (Cursor, Claude Desktop, Antigravity) with zero configuration:
# Instant runner via npx:
npx -y tzero-mcp@latest
# Or via Python package:
pip install tzero-mcp
tzero init
Links & Code:
- GitHub Repository (Apache-2.0): GitHub - toprakahmetaydogmus/TZeroAlgorithm: Deterministic AST Context Compressor & MCP Server for Cursor, Claude & Local LLMs. Cuts prompt tokens by 85–95% with 100% Zero-Leak security. · GitHub
- Live Web Hub & Benchmarks: tzero-indol vercel
How is the community currently handling multi-file repository context for agentic coding workflows? Do you rely on static symbol graphs, vector RAG, or AST-based pruning? Would love to exchange insights and feedback!