# T-Zero (Token Zero) Context Architect & MCP Suite
> Version: 11.15.5 | License: AGPL-3.0-only | Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
> Repository: https://github.com/toprakahmetaydogmus/TZeroAlgorithm
> Live Benchmark: https://tzero-indol.vercel.app | PyPI: https://pypi.org/project/tzero-mcp/ | npm: https://www.npmjs.com/package/tzero-mcp

## Executive Summary
T-Zero is a 100% free, local-first, deterministic AST codebase context compressor and canonical Model Context Protocol (MCP) server designed for AI coding assistants (Cursor, Claude Desktop, Claude Code, Windsurf, Copilot, Antigravity).

T-Zero solves context window bloat and expensive token costs:
- Slashes prompt context tokens by 85% to 95% using deterministic AST signature extraction.
- Completely preserves type signatures, class hierarchies, docstrings, imports, and interface contracts while pruning implementation bodies.
- 100% Zero-Leak security certified: Shannon entropy scanner (H >= 4.75) detects and redacts secrets/credentials locally.
- 0.0% Hallucination rate: Pre-flight reality lock mathematically validates imports and call signatures against the live workspace AST.
- 628 automated tests passing with 0 errors (100% green).

## Quick Start for Developers & AI Agents

### 1. Installation (1-Click)
```bash
# Option A: via pip (Python 3.10+)
pip install tzero-mcp

# Option B: via npm / npx (Zero-install)
npx tzero-mcp

# Option C: 1-Click Auto-Configure all installed IDEs (Cursor, Claude, Windsurf, VS Code)
tzero install-ide
```

### 2. Configure into IDEs as an MCP Server

#### For Cursor (`~/.cursor/mcp.json` or `.cursor/mcp.json`):
```json
{
  "mcpServers": {
    "tzero": {
      "command": "python",
      "args": ["-m", "tzero.tzero_mcp"]
    }
  }
}
```

#### For Claude Desktop (`claude_desktop_config.json`):
```json
{
  "mcpServers": {
    "tzero": {
      "command": "python",
      "args": ["-m", "tzero.tzero_mcp"]
    }
  }
}
```

### 3. CLI Commands
- `tzero --tree .` : Generate 4-tier hierarchical AST context tree (-88% to -95% token reduction).
- `tzero --benchmark` : Run multi-model token savings & financial ROI benchmark.
- `tzero --cost` : Display real-time token cost & financial ROI comparison across Claude 3.7, GPT-4o, Gemini 2.5.
- `tzero --drift` : Measure prompt instruction adherence and architectural drift score (0-100).
- `tzero --guard` : Pre-commit zero-leak credential scanner & AST syntax barrier.
- `tzero pc-fixer` : Autonomous self-healing doctor repairing broken imports, syntax, and environment bugs.
- `tzero share` : 1-click viral share hub for Twitter/X, Reddit, Hacker News, LinkedIn, WhatsApp.
- `tzero install-ide` : Detect and auto-configure all installed IDE clients.

## MCP Tools Reference (21 Canonical Tools)
When T-Zero is added as an MCP server, it exposes the following tools:
1. `build_project_context`: Scans directory and produces multi-tier AST context tree.
2. `prune_code_snippet`: Prunes in-memory code down to compact interface signatures.
3. `manage_architecture_rules`: Loads or updates architectural boundaries in `tzero.rules.json`.
4. `enforce_architecture_rules`: Audits inward-only dependencies and detects circular imports.
5. `generate_architecture_blueprint`: Synthesizes comprehensive ARCHITECTURE.md with Mermaid diagrams.
6. `analyze_code_dependencies`: Maps imports, exports, and internal vs external package dependencies.
7. `analyze_change_impact`: Calculates change blast radius (0-100) before modifying symbols.
8. `search_codebase`: 100% private local BM25 hybrid semantic code search with $0 cloud embedding cost.
9. `audit_code_quality`: Static AST code smell audit and cyclomatic complexity check.
10. `verify_security_guard`: Shannon entropy scanner detecting hardcoded API keys and tokens.
11. `estimate_token_cost`: Compares exact costs across OpenAI, Anthropic, Gemini, and DeepSeek.
12. `query_memory_store`: Persistent key-value memory store for multi-turn agent coordination.
13. `manage_memory_store`: Writes, updates, or deletes agent memory records.
14. `orchestrate_agent_swarm`: Coordinates multi-agent subtasks and consensus synthesis.
15. `build_ast_snapshot`: Creates instant local AST index cache for lightning-fast retrieval.
16. `heal_hallucinated_code`: Statically detects hallucinated methods and auto-corrects to real symbols.
17. `prove_zero_hallucination`: Mathematical and empirical reality-lock proof benchmark.
18. `transpile_model_bridge`: Zero-cost cross-language type bridge (Python to TypeScript, Go, Rust).
19. `diagnose_and_heal_system`: Autonomous environment and workspace health doctor.
20. `generate_architectural_passport`: Generates full cryptographic architectural passport.
21. `execute_codebase_workflow`: Executes multi-stage agent workflows deterministically.

## Architecture & Verification
- Language: Python (>=3.10)
- Verification Command: `python -m unittest discover tests -v` (628 tests, 100% pass)
- Lint Check: `flake8 .` (0 errors)
- Security: 100% Zero-Leak certified (no network telemetry, runs air-gapped).
