Skip to main content
Glama

Token Saver

CI License: MIT

A Claude Code plugin and MCP server that makes Claude read less and still understand more. Instead of whole files, long logs or giant JSON, Claude gets compact views: outlines, single functions, grouped search hits, log digests and JSON shapes.

Read-only, sandboxed to the project folder, no network.

Measured savings

Measured with npm run bench on four public repositories (express, requests, godot-demo-projects, ripgrep), three real logs (npm, pip, vitest) and three JSON files (a lockfile, PyPI and npm registry metadata):

Task

Cases

Built-in tools

Token Saver

Saved

Understand a file (outline instead of Read)

129

571k

53k

91%

Read one function (outline + read_symbol)

129

571k

91k

84%

Edit one function (outline + read_symbol + partial Read)

129

571k

128k

78%

Search a symbol (search_compact instead of Grep)

40

68k

13k

81%

Log / command output (digest)

3

24k

3.6k

85%

JSON structure (json_shape instead of Read)

3

27k

2.8k

90%

How it was measured, so you can judge it:

  • Files are source files with at least 150 lines; for small files the saving is smaller and reading them is fine.

  • Baselines are conservative: Read is capped at 2,000 lines / 25k tokens, Grep at 250 lines, Bash at 30,000 characters, as in Claude Code. Real full reads are often larger.

  • Tokens are counted with the o200k tokenizer because Claude's tokenizer is not public. Absolute numbers differ, ratios are comparable.

  • The "Edit" row counts the extra partial Read that Claude Code's Edit tool needs.

  • Fixed cost: the tool definitions take about 600 tokens per request (o200k), which one avoided full read usually pays back.

Related MCP server: token-saver-mcp

Install

/plugin install token-saver --marketplace tobertraubling2004-design/Token_Saver

On Claude Code older than 2.1.275: /plugin marketplace add tobertraubling2004-design/Token_Saver, then /plugin install token-saver@token-saver.

The plugin brings the bundled server (no npm install) and a Read hook: the first time in a session Claude tries to read a large file (≈6k tokens or more) in full, the hook suggests the cheaper tools. Repeating the same Read goes through. Set TOKEN_SAVER_GUARD=off to disable it, or TOKEN_SAVER_GUARD_TOKENS=12000 to change the threshold.

MCP server only

Requires Node.js 20+.

git clone https://github.com/tobertraubling2004-design/Token_Saver.git
cd Token_Saver && npm install && npm run build

# Claude Code
claude mcp add token-saver -- node /path/to/Token_Saver/dist/index.js

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "token-saver": {
      "command": "node",
      "args": ["/path/to/Token_Saver/dist/index.js", "--root", "/absolute/path/to/project"]
    }
  }
}

Tools

Tool

Instead of

Returns

project_map

ls -R, opening files to look around

Folder tree with token cost per entry (gitignore applied); on a file, its token cost

file_outline

Reading a file to see what is in it

Classes, functions, types, headings with line numbers

read_symbol

Reading a file for one function

Only that function's or class's body

read_slice

Reading a file for lines X–Y

Numbered line range, max 400 lines

search_compact

Raw grep dumps

Hits grouped per file, max 8 per file, long lines clipped around the match

digest_log

Pasting logs

Repeated lines grouped (×200), errors and warnings kept, head and tail

json_shape

Reading big JSON/JSONL

Keys, array lengths, maps collapsed, one sample per field

Command output can be condensed before it reaches the context:

npm test 2>&1 | token-saver-mcp digest        # or: node <plugin>/plugin/server.mjs digest

The server tells Claude the exact command in its instructions.

Outlines: TypeScript/JavaScript, Python, GDScript (Godot), C/C++ (incl. Unreal headers), C#, Java, Kotlin, Swift, Objective-C, Go, Rust, Lua, Ruby, PHP, shell, Markdown. Regex based: fast and dependency free, good for navigation, not a full parser.

Configuration

Setting

Effect

--root <dir> / TOKEN_SAVER_ROOT / CLAUDE_PROJECT_DIR / current dir

The only tree the server may read

TOKEN_SAVER_QUIET=1

Hide the [-91%: …] savings footer

TOKEN_SAVER_NO_GITIGNORE=1

Do not apply .gitignore rules

Safety

  • Read-only: no writes, no shell, no network.

  • Paths outside the root, including symlinks pointing out, are rejected.

  • Binary files, lockfiles and build/cache folders are skipped.

  • Bad input never crashes the server; errors come back as tool results.

Development

npm install
npm test               # vitest
npm run typecheck
npm run build          # dist/ for npm
npm run build:plugin   # plugin/server.mjs, commit it
npm run bench -- --repos <dir...> --logs <file...> --json <file...>

See CONTRIBUTING.md and CHANGELOG.md.

License

MIT

Available Tools

7 tools
digest_logA
Read-onlyIdempotent

Condense a log: repeats grouped (×N), errors/warnings kept. Pass path; text only for output you already have.

Inputs: path, text, maxLines.

file_outlineB
Read-onlyIdempotent

Functions/classes/types/headings of a file with line numbers.

Inputs: path (required).

json_shapeC
Read-onlyIdempotent

Structure of a JSON/JSONL file: keys, array lengths, sample values.

Inputs: path (required).

project_mapA
Read-onlyIdempotent

Folder tree with token cost per entry (gitignore applied). Use first.

Inputs: path, depth, maxPerDir.

read_sliceC
Read-onlyIdempotent

Lines start-end (1-based, max 400).

Inputs: path (required), endLine (required), startLine (required).

read_symbolC
Read-onlyIdempotent

Body of one function/class by name.

Inputs: path (required), symbol (required), maxLines.

search_compactB
Read-onlyIdempotent

Grep the project; hits grouped per file, lines clipped. Literal, case-insensitive by default.

Inputs: query (required), glob, path, regex, +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct inspection granularity: project tree, file outline, symbol body, line slice, grep search, log condensation, and JSON structure. The only apparent overlap is between file_outline/read_symbol/read_slice, but their descriptions make the boundaries clear. An agent can reliably choose the right tool.

    Naming Consistency4/5

    All names use consistent snake_case and are concise and readable. The pattern mixes noun-first names (project_map, file_outline, json_shape) with verb-first names (read_symbol, read_slice, search_compact, digest_log), but this is a minor deviation rather than confusion.

    Tool Count5/5

    Seven tools is well-scoped for a token-efficient codebase/log inspection server. Each tool covers a distinct exploration need without obvious redundancy.

    Completeness4/5

    The surface covers the core read-only inspection workflow: project structure, file outline, symbol extraction, line ranges, search, log summaries, and JSON shape. Minor gaps exist, such as no regex search or explicit multi-file/batch read operation, but agents can work around these with the provided tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude Code to reduce token usage by 70-90% using a local LLM for codebase indexing, tool output compression, and turn summarization.
      63 npm
      3
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Automatically reduces token usage in Claude Code sessions using algorithmic optimizations like code compression, smart file reading, output summarization, and prompt rewriting, with no extra API calls or cost.
      1
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Reduces context window usage by 60-90% through intelligent caching, compression, and smart tool replacements for Claude Code and Claude Desktop.
      2,943 npm
      594
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to retrieve focused, bounded repository context locally and read-only, reducing token usage while never modifying the repository or executing its code.
      -