# MCP-Drift-State-Tracker An industrial-grade Model Context Protocol (MCP) server engineered to enforce code completeness, intercept context erosion, and neutralize LLM laziness across multi-language repository workspaces. Optimized for local, high-throughput developer stacks (such as Odysseus, Aider, and Hermes driving local Ollama instances), this tracker acts as a deterministic pre-commit and post-mutation gatekeeper. It eliminates the "laziness trap" (where local models substitute production code with `pass`, `todo!()`, or comments) and the "truncation trap" (where attention compression causes functions to collapse mid-generation). --- ## ? Core Architecture Unlike fragile pattern-matching text scanners, `MCP-Drift-State-Tracker` evaluates code modifications using language-aware structural definitions: 1. **Python AST Driver:** Uses native compilation parsing (`ast`) to capture an explicit footprint of every class, function signature, decorator chain, and package dependency. 2. **Deterministic Brace Scoping Engine:** Tracks character-by-character lexical nesting depths to monitor structural boundaries across curly-brace ecosystems, including **Rust, Go, TypeScript, JavaScript, C, C++, Java, and C#**. 3. **State Persistence Layer:** Automatically stores baseline repository structures securely inside a hidden workspace index (`.mcp_drift_state.json`), ensuring tracking metrics survive agent crashes or tool stack restarts. --- ## ? Interception Capabilities * **The Laziness Trap:** Instantly flags and rejects mutations that introduce placeholder stubs or shortcuts (`pass`, `NotImplementedError`, `todo!()`, `panic!()`, `// Insert code here`). * **The Compression Trap:** Monitors line-span volatility. If an LLM drops code to save token context window allocations, any function or scope contraction exceeding 50% triggers an immediate blocker. * **The Dependency Vault:** Catches subtle regressions where a model strips package imports, type hints, or critical API annotations (such as `@mcp.tool()` or `#[inline]`) during extensive refactors. --- ## ? Installation & Integration ### Prerequisites Manage execution isolation cleanly via `uv` to preserve a pure bare-metal host environment: ```bash # Verify uv availability uv --version