MCP server to reduce input token costs when sending code to AI agents through syntax-aware code minification.
A high-performance Model Context Protocol (MCP) server and CLI tool engineered to drastically reduce token consumption when coding with AI assistants (Claude, Cursor, Gemini, Copilot, Windsurf).
It intercepts code sent to LLMs, compacts it to minimal tokens, enforces surgical SEARCH/REPLACE diffs, and validates Abstract Syntax Tree (AST) integrity alongside automated Prettier formatting.
- The Problem: Sending full, boilerplate-heavy, indented source files to LLMs rapidly exhausts context windows, degrades attention ("lost in the middle" phenomenon), and drives up API costs. - The Solution: mcp-token-optimizer minifies source code structurally before delivery to the model, reducing context consumption by 10% to 30%. When the AI replies with surgical edits, the server restores formatting via Prettier, verifies that the AST is intact (preventing syntax breakage), and snapshots changes with undo capability.
- Token Compaction (readfile): Strips non-essential indentation, blank lines, and whitespace while strictly safeguarding strings and syntax. - 🩺 Surgical Edits with AST Validation (applycodeedit): Applies diffs using REPLACE blocks. Automatically validates syntax via Tree-sitter and formats with Prettier before saving to disk. - Snapshot & History Manager: Keeps historical snapshots of files prior to edits with undo and roll-back capabilities. - Project Token Scanner (scanproject): Analyzes whole repositories and reports potential token savings and file-by-file optimization rates. - Real-time Session Analytics (getoptimizerstatus): Monitors read operations, edit count, t
From the project README.
Add the radar badge to your README — it shows your project was picked up by MCP Radar and links to this page:
[](https://mcp.liqiwa.com/s/LucasPortinho--mcp-token-optimizer.html)
ChatGPT thinks. Codex works. Use ChatGPT as the planning brain while keeping the Codex harness.
shinthink/blitzstrike⚡ Blitz Strike — a universal MCP penetration-testing toolbelt. Structured methodology: reconnaissance & attack-surface mapping, source-to-sink analysis, and live validation. 57 escalation chains, 130-
0xwilliamortiz/openclaude-improvedruns anywhere. uses anything
halofyai/halofyHalofy is the open access and governance layer for AI agents across your organization. Identity, policy, provenance, audit, and signed erasure.
CaptureGrubEnchant/SolidWorksSolidWorks MCP Server connects an AI assistant to a running SolidWorks instance. Sketch, extrude, fillet, export STEP/STL, generate macros.
arielshad/3d-asset-server3d assets api and mcp
The top new MCP servers of the week, every Monday. No spam, unsubscribe anytime.