# T-Zero
**High-performance AST context pruner & MCP server for AI coding assistants.**
Reduces codebase prompt tokens by up to **94.9%** while preserving complete class contracts, typed signatures, and cross-file dependencies.
[](https://pypi.org/project/tzero-mcp/)
[](https://pypi.org/project/tzero-mcp/)
[](https://pypi.org/project/tzero-mcp/)
[-34d399?style=flat-square&logo=checkmarx)](https://glama.ai/mcp/servers)
[](https://github.com/toprakahmetaydogmus/TZeroAlgorithm/actions)
[](https://github.com/toprakahmetaydogmus/TZeroAlgorithm#security-architecture)
[-10b981?style=flat-square&logo=probot)](https://github.com/toprakahmetaydogmus/TZeroAlgorithm#core-capabilities)
[](LICENSE)
[Why T-Zero](#why-t-zero) • [Quickstart](#quickstart) • [Benchmarks](#reproducible-benchmarks) • [Tools Reference](#mcp-tools-reference) • [Architecture](#architecture) • [Türkçe](#turkce)
---
## Why T-Zero?
When an AI coding assistant (Cursor, Claude Code, Antigravity IDE, Windsurf, Cline) reads your codebase, feeding full source files wastes **80% to 95% of your context window** on internal loop bodies, routine calculations, and local variables. The model needs to know *what* your modules expose and call, not 100 lines of boilerplate implementation inside each method.
**T-Zero** acts like an on-the-fly `.pyi` / `.d.ts` declaration generator for your AI context window:
```
┌─────────────────────────────────┐
│ Full Source Codebase │ (166,996 raw tokens — $0.50/query, 18s latency)
└────────────────┬────────────────┘
│
▼ [ T-Zero Native AST Parser ]
│ Strips routine bodies, preserves signatures, types & docs
▼
┌─────────────────────────────────┐
│ T-Zero AST Skeleton Tree │ (8,465 tokens — $0.025/query, 2.1s latency)
└─────────────────────────────────┘
```
### Before vs. After AST Pruning
```python
# BEFORE: Raw source file (1,240 tokens)
class PaymentGateway:
def __init__(self, api_key: str, timeout: int = 30):
# 30 lines of connection pooling, socket configuration, SSL contexts...
self.session = requests.Session()
self.timeout = timeout
...
def process_charge(self, user_id: str, amount_cents: int, currency: str = "USD") -> TransactionResult:
"""Charges a customer card with automated retry and idempotency."""
# 60 lines of payload hashing, error handling, database locking, telemetry...
if not user_id:
raise ValueError("user_id required")
...
# AFTER: T-Zero AST Skeleton (64 tokens — 94.8% reduction)
class PaymentGateway:
def __init__(self, api_key: str, timeout: int = 30): ...
def process_charge(self, user_id: str, amount_cents: int, currency: str = "USD") -> TransactionResult:
"""Charges a customer card with automated retry and idempotency."""
...
```
The AI assistant retains full access to class names, typed parameters, docstrings, and return types — with **zero semantic loss**, at a fraction of the token cost, and with drastically faster Time-To-First-Token (TTFT).
---
## Quickstart
### 1. ⚡ One-Click Auto-Install (Zero Configuration)
Automatically detect and configure Cursor, Claude Desktop, Antigravity IDE, Windsurf, Cline, and VS Code in 5 seconds with zero manual JSON editing:
```bash
uvx tzero-mcp --add-mcp
# or using pipx
pipx run tzero-mcp --add-mcp
```
### 2. Instant Run via uvx or pipx (Zero Installation)
```bash
# Launch MCP server stdio transport instantly:
uvx tzero-mcp
# or:
pipx run tzero-mcp
```
### 3. Install via pip
```bash
pip install tzero-mcp
```
### 4. Manual Configuration for Cursor / Claude Desktop / Antigravity / Windsurf
Add the following to your `claude_desktop_config.json` or Cursor Settings (`Features` → `MCP`):
```json
{
"mcpServers": {
"tzero": {
"command": "uvx",
"args": ["tzero-mcp"]
}
}
}
```
*Or using local python:*
```json
{
"mcpServers": {
"tzero": {
"command": "python",
"args": ["-m", "tzero_mcp"]
}
}
}
```
### 5. Claude Code CLI Integration
```bash
claude mcp add --scope user tzero uvx tzero-mcp
```
### 6. Launch Local Web Dashboard
```bash
tzero --dashboard
```
Opens the local browser dashboard on `http://localhost:8421` featuring interactive dependency graphs and the live AST pruner sandbox.
### 7. 🛡️ Pre-Commit Hook (Auto Zero-Leak & Token Guard)
Prevent accidental credential leaks and token bloat before code ever leaves developer machines. Add to your `.pre-commit-config.yaml`:
```yaml
repos:
- repo: https://github.com/toprakahmetaydogmus/TZeroAlgorithm
rev: v8.0.1
hooks:
- id: tzero-guard
- id: tzero-audit
```
### 8. ⚡ GitHub Actions CI/CD Integration
Automatically audit repositories for zero hardcoded secrets and generate token optimization summaries on every commit and PR:
```yaml
# .github/workflows/tzero.yml
name: T-Zero Codebase Guard
on: [push, pull_request]
jobs:
tzero-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: toprakahmetaydogmus/TZeroAlgorithm@main
with:
workspace-dir: '.'
audit-level: 'strict'
```
### 9. 🏅 Badge of Honor: Show Your Repo is Context-Optimized
If your repository, library, or framework is optimized for AI coding assistants using T-Zero, embed our official badge in your `README.md`. This signals to developers and AI coding agents that your repository can be ingested with 90%+ less token overhead:
```markdown
[-blue?style=flat-square&logo=python)](https://github.com/toprakahmetaydogmus/TZeroAlgorithm)
```
**Live Preview:**
[-blue?style=flat-square&logo=python)](https://github.com/toprakahmetaydogmus/TZeroAlgorithm)
*Dark Mode / Slate variant:*
```markdown
[-38bdf8?style=flat-square&logo=python&labelColor=0f172a)](https://github.com/toprakahmetaydogmus/TZeroAlgorithm)
```
---
## Reproducible Benchmarks