π‘οΈ Edit Math Supervisor (MCP Server)
Architectural Gatekeeper for AI Coding Assistants.
Edit Math Supervisor is an advanced Model Context Protocol (MCP) server that acts as a Stateful Gatekeeper for AI coding assistants (Claude Desktop, Roo Code, Cline, Lingma).
It prevents "Tunnel Vision" by forcing the AI to verify code dependencies before editing. Unlike simple linters, this server physically blocks file saving until the AI proves that the changes are safe.
β¨ Key Features
AST Parsing (Tree-sitter): Accurate dependency detection for JavaScript and TypeScript. Understands classes, nested functions, and
thiscontext.Stateful Gatekeeper: The server tracks verification status. The
commit_safe_edittool returnsβ ACCESS DENIEDif the Integrity Score is not 1.0.Interactive Conflict Resolution: If the AI detects breaking changes or cannot verify an external dependency, the server forces it to ask the user for permission before proceeding.
Smart Filtering: Automatically ignores standard language methods (e.g.,
.map(),console.log) to keep the focus on your business logic.
π The "#editmath" Protocol
The server enforces a strict workflow:
π SCAN: The AI scans the target function using AST.
π« TICKET: The AI verifies dependencies. If conflicts exist, it must ask the user for confirmation.
πΎ COMMIT: Only with a valid ticket (or user override) can the AI save changes.
π¦ Installation
Clone the repository:
git clone https://github.com/your-username/mcp-edit-math.git cd mcp-edit-mathInstall dependencies: Note: Specific versions are recommended for stability.
pip install mcp tree-sitter==0.21.3 tree-sitter-javascript==0.21.0 tree-sitter-typescript==0.21.0Configure your MCP Client: Add this to your configuration file (e.g.,
claude_desktop_config.json):{ "mcpServers": { "edit-math": { "command": "python", "args": ["/absolute/path/to/mcp-edit-math/mcp_edit_math.py"] } } }
π€ System Prompt (Required)
Add this to your AI's Custom Instructions or .cursorrules to activate the protocol: