token-optimizer-mcp GEMINI.md

Instructions for using a token-optimizer service in Gemini CLI. The service reduces the amount of file and session information the agent needs to process by caching, comparing, and compressing text.

In plain words
What is it for?
Use it when reading large files, searching an unfamiliar codebase, editing large files, measuring token use, or storing bulky text outside the active session.
Why use it?
Large files and repeated readings can use a lot of context, which may make work slower or leave less room for the task. These instructions identify when to use the optimizer's tools.

Instructions file for Gemini CLI

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/ooples/token-optimizer-mcp/gemini-md
Clone the repo
git clone --depth 1 https://github.com/ooples/token-optimizer-mcp

Made for: Gemini CLI.

Per session 293 This file is loaded in full into every session.
When invoked 293 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00293 $0.00293
Opus 5 $0.00147 $0.00147
Sonnet 5 $0.00059 $0.00059
Haiku 4.5 $0.00029 $0.00029

Measured 2d ago against content hash a01706052cce, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

token-optimizer-mcp GEMINI.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

GEMINI.md · 20 lines

What it actually says

Token optimization (Gemini CLI)

This extension adds the token-optimizer MCP server. Its tools cut context/token usage 60–90% via caching, diffing, and compression. Prefer them:

  • smart_read instead of reading a file directly when the file is large (>~400 lines / >25 KB) or already read this session — re-reads return a diff.
  • smart_glob instead of a content grep on a big/unknown tree — returns paths only; read only what you need.
  • smart_edit on large files — returns a compact diff, not the whole file.
  • optimize_session when context fills up; get_session_stats for savings.
  • get_optimization_report to show the user total tokens saved with a full breakdown by action/hook/server (returns a ready-to-display formatted summary).
  • optimize_text to stash bulky text out-of-context under a key. compress_text is at-rest byte compression only — its base64 output usually costs more tokens, so never put it back into context.
  • count_tokens to measure a chunk first.

Small files / one-off reads: built-in reading is fine — don't add overhead.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 20 lines · 293 tokens per session scan A a01706052cce

Subscribe to this mod's changes

token-optimizer-mcp GEMINI.md is an instructions file published in the GitHub repository ooples/token-optimizer-mcp (501 stars, last pushed 2d ago), licensed MIT. It adds 293 tokens to every session, about $0.0015 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.