Project Spotlight

Token Optimizer

An intelligent Model Context Protocol (MCP) server that runs build, lint, and test suites and compresses massive, noisy diagnostic output into compact, actionable verdicts for AI coding agents.

Context Slashing

Transforms megabytes of repetitive compiler errors, lint warnings, and test logs into high-signal summaries, slashing context token consumption by up to 90%.

Targeted Triage

Isolates root-cause failure excerpts, stack traces, and affected files on disk while keeping raw terminal output out of the agent's context window.

Universal Agent Support

Ships with an automated npx installer supporting Claude Code, Cursor, Codex, Antigravity, and OpenCode across Gateway, OpenRouter, and local LLM backends.

What I Built

I created Token Optimizer to solve one of the most expensive friction points in agentic coding: context bloat from verbose build and test logs. By acting as an MCP-compliant execution proxy, Token Optimizer intercepts diagnostic commands, stores raw logs locally in the workspace, and returns concise verdicts, regression checks, or failure triage summaries directly to the AI agent.

90%+

Context token savings

5 clients

IDE & agent support

1-cmd

Transactional installer

Key Features

  • Compact test verdicts (run_test_verdict) summarizing passes, failures, and execution timings.
  • Targeted failure triage (run_failure_triage) identifying root causes and file locations.
  • Local workspace log querying (query_log, grep_log) without polluting conversation history.
  • Codebase pre-scouting (scout_codebase) to identify relevant files before expansive agent searches.
  • Diff review before validation (run_changed_files_review) to catch errors early.
  • Deterministic regression checking (run_regression_check) comparing test results against baseline runs.
  • Transactional CLI installer (@softawarest/token-optimizer-installer) with automatic client discovery.
  • Multi-provider flexibility supporting LLM Gateway tokens, custom OpenRouter keys, and local OpenAI-compatible endpoints.
  • Granular execution policies with built-in protection against unsafe command execution.

Technical Architecture

Token Optimizer is built as a TypeScript Model Context Protocol (MCP) server communicating via JSON-RPC over stdio. Commands execute inside managed child process sandboxes where stdout and stderr streams are buffered and parsed by heuristic pattern matchers. If diagnostic summarization requires deeper semantic reasoning, the server routes condensed excerpts through an LLM triage layer via OpenRouter or local models.

Stack at a Glance

Core Engine

TypeScript, Node.js, Model Context Protocol (MCP) SDK

Runtime & Parsers

child_process streaming, Regex diagnostic parsers, Workspace caching

Integrations

Claude Code, Antigravity, Cursor, Codex, OpenCode, OpenRouter, Local LLMs

Developer Experience

The project includes a robust installer package with doctor, repair, and uninstall lifecycle commands that detect installed developer tools and safely write MCP configuration files. Strict TypeScript typing across MCP tool schemas ensures reliable tool calling and seamless integration with modern agent runtimes.

Outcome

Token Optimizer significantly reduces API token costs and prevents model context saturation during complex pair-programming workflows. By keeping terminal logs off the model's wire and presenting structured verdicts, coding agents resolve bugs faster and with greater accuracy.

Install Token Optimizer in your coding agent, explore the tools, or check out the open-source GitHub repository. https://github.com/lefos13/token-optimizer.