$git clone https://github.com/ooples/token-optimizer-mcp> Give Codex, Claude, Cursor, and other MCP clients more room to think with cached context, compact diffs, smart tools, and visible token-savings reports.
| 1 | # Token Optimizer MCP |
| 2 | |
| 3 | > Give Codex, Claude, Cursor, and other MCP clients more room to think with cached context, compact diffs, smart tools, and visible token-savings reports. |
| 4 | |
| 5 | [](https://www.npmjs.com/package/@ooples/token-optimizer-mcp) |
| 6 | [](https://github.com/ooples/token-optimizer-mcp/actions/workflows/ci.yml) |
| 7 | [](https://nodejs.org/) |
| 8 | [](./LICENSE) |
| 9 | |
| 10 | Token Optimizer is a local [Model Context Protocol](https://modelcontextprotocol.io/) server. It reduces the text sent back into an agent's context by caching large payloads, returning diffs on repeated reads, filtering noisy command output, and recording the result of every measurable optimization. |
| 11 | |
| 12 | - **74 MCP tools** in the current release |
| 13 | - **No hosted service required** for core caching and compression |
| 14 | - **SQLite-backed persistence** across conversations |
| 15 | - **Brotli compression** with token-aware keep-or-skip decisions |
| 16 | - **Built-in savings reports** by tool, hook phase, and MCP server |
| 17 | |
| 18 | ## Installation |
| 19 | |
| 20 | Every client launches the same stdio server—`npx -y @ooples/token-optimizer-mcp@latest`—but each client has its own instruction and lifecycle APIs. The ready-made integrations below use those native APIs; they do not pretend Claude Code's seven-phase PowerShell hook system is portable unchanged. |
| 21 | |
| 22 | | Client | Fastest MCP setup | Best-experience integration | |
| 23 | | ------------------ | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------- | |
| 24 | | Codex | `codex mcp add token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest` | Codex plugin: MCP + skill + lifecycle hooks | |
| 25 | | Claude Code | `claude mcp add --transport stdio --scope user token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest` | Claude plugin: MCP + skill + large-read hook | |
| 26 | | GitHub Copilot CLI | `copilot mcp add token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest` | `AGENTS.md` + repository lifecycle hooks | |
| 27 | | Gemini CLI | `gemini mcp add --scope user token-optimizer npx -y @ooples/token-optimizer-mcp@latest` | Gemini extension: MCP + context + lifecycle hooks | |
| 28 | | OpenCode | Add the `mcp` block below to `opencode.json` | `AGENTS.md` + local plugin + compaction preservation | |
| 29 | |
| 30 | ### Codex |
| 31 | |
| 32 | #### 1. Add the MCP server or native plugin |
| 33 | |
| 34 | For the best experience, install the Codex plugin. It bundles the MCP server, the token-optimization skill, session guidance, and a large-read hook: |
| 35 | |
| 36 | ```bash |
| 37 | codex plugin marketplace add ooples/token-optimizer-mcp |
| 38 | codex plugin add token-optimizer@token-optimizer |
| 39 | ``` |
| 40 | |
| 41 | Review and trust the bundled hooks with `/hooks`, then start a new conversation. If you prefer an MCP-only installation, use: |
| 42 | |
| 43 | ```bash |
| 44 | codex mcp add token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest |
| 45 | ``` |
| 46 | |
| 47 | On Windows, if PowerShell blocks the `codex.ps1` shim, use the command launcher directly: |
| 48 | |
| 49 | ```powershell |
| 50 | codex.cmd mcp add token-optimizer -- npx -y @ooples/token-optimizer-mcp@latest |
| 51 | ``` |
| 52 | |
| 53 | This writes the server to `~/.codex/config.toml`. Codex CLI, the Codex IDE extension, and the Codex app on the same host share that configuration. |
| 54 | |
| 55 | #### 2. Verify the installation |
| 56 | |
| 57 | ```bash |
| 58 | codex mcp get token-optimizer |
| 59 | codex mcp list |
| 60 | ``` |
| 61 | |
| 62 | ![Codex MCP list showing token-optimizer installed and enabled](./docs/assets/codex-mcp-installed. |