mcp-edit-math
Architectural Gatekeeper for AI coding. Prevents "tunnel vision" bugs by forcing the AI to verify dependencies (via AST parsing) before editing files. Supports JavaScript & TypeScript. Blocks unsafe edits until the AI proves it understands the impact
README
🛡️ 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-math -
Install 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.0 -
Configure 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:
=== 🛡️ EDIT MATH PROTOCOL ===
Trigger: When user types "#editmath".
You are operating under a strict safety protocol. Direct file editing is FORBIDDEN.
Follow this sequence precisely:
1. 🔍 SCAN: Call `scan_dependencies(code, target_function)`.
- Determine `language` ("js", "ts") based on file extension.
2. 🎫 GET TICKET: Call `calculate_integrity_score`.
- **If server returns "STRICT MODE INTERVENTION":**
a. STOP. Do not proceed.
b. ASK THE USER: Explain the plan/conflicts and ask "Do you approve?".
c. WAIT for the user's "Yes".
d. RE-CALL `calculate_integrity_score` with `user_confirmed=True`.
3. 💾 COMMIT: Call `commit_safe_edit`.
- If you need to force a commit (e.g., for unverified external libs), ask the user first, then use `force_override=True`.
### 🧘♀️ Philosophy: The Meta-Project
This project is a result of **pure Vibecoding**.
It was built *by* an AI, *for* AIs.
I realized that while AI coding is powerful, it lacks architectural awareness. So, I directed **Google Gemini** to build its own "Supervisor" — a tool that forces it to pause, think, and verify dependencies before writing code.
It is a self-correcting mechanism for the AI-assisted development era.
<a id="donate"></a>
## ☕ Support the Project
If this tool saved you time or prevented a bug, you can support the development via crypto:
* **EVM (Ethereum / Base / BNB):** `0x13cA48D52bd7bB4f12Daa39730299b21c6DaA566`
* **Solana:** `3TPUjSQ77GaCESp1Dugt8AjQJaD51jHAtckEQNLuWd83`
* **Bitcoin:** `bc1qsles2ylewztk5297hnmfqwmjt2lk9qgchd78at`
---
License: Apache-2.0
Author: Annenkov Yuriy
**Co-authored with:** Google Gemini
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.