Skip to main content
Glama
KaryawanSurga

TokenSaver MCP

TokenSaver MCP

CI Node License: MIT

Stop burning context tokens on files that don't matter.

TokenSaver MCP is an offline Model Context Protocol server that gives coding agents a compact map of any repository in one call: filtered file tree, language stats, entry points, and key symbols — capped by an explicit token budget. Instead of reading dozens of files to orient itself, an agent asks for the map and reads only what it needs.

Product requirements: PRD.md · PRD.id.md (Bahasa Indonesia)

Why

Agents navigate repositories by reading files until they understand the layout. That burns context, costs money, and pushes the actual task out of the window. TokenSaver answers the orientation questions in a single, deterministic, budgeted response:

  • Where does this project start executing?

  • Which files and directories exist (minus dependencies and build output)?

  • What functions, classes, and interfaces live where?

No network, no API keys, no telemetry. Every tool is read-only.

Related MCP server: mcp-codemap

Tools

Tool

What it returns

repo_map

Compact map: file tree, language stats, entry points, and key symbols, trimmed to a token budget.

find_symbol

Every matching function, class, interface, type, enum, constant, or method with file, line, and visibility.

file_outline

Structure of one JS/TS file — declarations with line ranges, including class methods.

entry_points

Detected entry points from package.json (bin, main, exports), bin/ scripts, index/cli conventions, and Python modules.

Example output

Running repo_map against this repository itself:

# TokenSaver map: TokenSaverMcp
Files: 30 | Languages: TypeScript 19 files, JSON 4 files, Markdown 3 files, Python 1 files

## Entry points
- src/index.ts (src/index.ts convention)

## Tree
* = entry point
.gitignore
CHANGELOG.md
LICENSE
package.json
README.md
tsconfig.json
src/
  index.ts *
  server.ts
  core/
    entrypoints.ts
    languages.ts
    scanner.ts
    symbols.ts
    tokens.ts
  tools/
    entry-points.ts
    file-outline.ts
    find-symbol.ts
    repo-map.ts
tests/
  scanner.test.ts
  server.test.ts
  symbols.test.ts
  tokens.test.ts
  fixtures/
    sample-repo/ (6 files)

## Symbols
() function, (C) class, (i) interface, (t) type, (e) enum, (c) const, (m) method, (n) namespace
src/index.ts: HELP(c), main()
src/core/scanner.ts: FileEntry(i), LanguageStat(i), RepoScan(i), scanRepository()
src/core/symbols.ts: SymbolInfo(i), extractSymbols()
src/core/tokens.ts: estimateTokens(), fitToBudget()
src/server.ts: SERVER_NAME(c), SERVER_VERSION(c), buildServer()

Roughly 650 estimated tokens for a full project overview — often less than reading a single source file.

Install

Run it directly with npx (no install):

npx -y tokensaver-mcp

Or install from source:

git clone https://github.com/KaryawanSurga/TokenSaverMcp.git
cd TokenSaverMcp
npm install
npm run build

Client configuration

Add the server to any MCP-compatible client.

{
  "mcpServers": {
    "tokensaver": {
      "command": "npx",
      "args": ["-y", "tokensaver-mcp"]
    }
  }
}

From a local checkout, point command at node and args at the built entry point:

{
  "mcpServers": {
    "tokensaver": {
      "command": "node",
      "args": ["/absolute/path/to/TokenSaverMcp/dist/index.js"]
    }
  }
}

Token budgeting

Every response states its estimated size. repo_map accepts a budget (approximate tokens, default 1500, max 20000) and trims the tree or symbol section to fit, telling you when it truncated. Token counts are approximated at four characters per token, which keeps the server dependency-free and offline.

Design principles

  • Offline and deterministic. Same repository, same output. No network calls, no model downloads, no environment discovery.

  • Read-only. Tools never write to the target repository.

  • Ignore-aware. .gitignore is respected, and dependency/build directories (node_modules/, dist/, .venv/, target/, …) are always skipped.

  • Safe by default. file_outline refuses to resolve paths outside the repository root.

  • Bounded output. Token budgets keep responses inside the context window.

Roadmap

  • Python symbol extraction (v0.2).

  • Import graph and reverse-dependency lookup.

  • --json output mode for scripting.

  • Repository snapshot diffing between git refs.

Development

npm install
npm run typecheck
npm run build
npm test

The test suite covers the scanner, symbol extraction, entry point detection, token budgeting, and in-memory MCP client/server round trips for every tool.

License

MIT — see LICENSE.

Available Tools

4 tools
entry_pointsEntry pointsA
Read-only

Detect where a repository actually starts executing: package.json bin/main/exports targets, bin/ scripts, index and cli conventions, and Python entry modules. Use it to orient before exploring or running a project.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the repository root

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, so side-effect disclosure is not needed. The description adds value by naming the exact locations inspected (package.json, bin/, index/cli conventions, Python entry modules), but it does not describe the output shape or behavior when no entry points are detectable. This is a moderate gap, not a contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tightly written sentences. The first front-loads the action and enumerates the resource, the second provides usage context. No redundancy or fluff; every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter, read-only detection tool, the description covers what it does, what it inspects, and when to use it. The lack of an output schema and return-format details is minor given the simple scope; an agent can call it to orient without needing additional prerequisites.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter path is fully documented in the schema ('Absolute path to the repository root'), giving 100% schema coverage. The description adds no further parameter semantics, which is acceptable; the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Detect where a repository actually starts executing' and then enumerates concrete targets (package.json bin/main/exports, bin/ scripts, index/cli conventions, Python entry modules). This clearly differentiates it from sibling tools like repo_map or file_outline, which concern mapping and outlining rather than startup entry points.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The second sentence provides an explicit use case: 'Use it to orient before exploring or running a project.' It doesn't name sibling alternatives or state exclusions, but the context is clear enough to route an agent toward this tool for initial orientation. No misleading guidance is present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

file_outlineFile outlineA
Read-only

List the structure of one JavaScript/TypeScript file — functions, classes (with methods), interfaces, types, enums, and constants with line ranges. Cheaper than reading the whole file when you only need its shape.

ParametersJSON Schema
NameRequiredDescriptionDefault
fileYesFile path relative to the repository root
pathYesAbsolute path to the repository root

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered. The description adds useful behavioral detail beyond that: it reports line ranges, limits scope to a single file, and lists the symbol kinds returned, which helps set expectations about output granularity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no wasted words. The core action and scope are front-loaded, the symbol list is compact but complete, and the value proposition ('cheaper than reading the whole file') earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only single-file listing tool with fully documented parameters, the description is largely complete: it tells the agent what will be listed and why it should be used. It does not describe the exact return format or failure modes, but those are minor given the tool's simplicity and the readOnlyHint annotation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%: both 'file' and 'path' have clear descriptions ('relative to the repository root' and 'absolute path to the repository root'). The tool description adds no parameter-level meaning, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'List the structure of one JavaScript/TypeScript file.' It enumerates exactly what is included (functions, classes with methods, interfaces, types, enums, constants, line ranges), and 'one file' clearly differentiates it from repository-wide tools like repo_map or entry_points.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'when you only need its shape' provides a clear use case, and 'cheaper than reading the whole file' gives the agent a cost-based decision signal. It does not explicitly name sibling tools or state when not to use it, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

find_symbolFind symbolA
Read-only

Find functions, classes, interfaces, types, enums, constants, or methods by name across JavaScript and TypeScript files. Returns file, line, kind, and visibility so you can jump straight to the definition.

ParametersJSON Schema
NameRequiredDescriptionDefault
kindNoRestrict matches to one symbol kind
pathYesAbsolute path to the repository root
limitNoMaximum matches to return (default 20)
queryYesCase-insensitive symbol name or fragment to search for

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered. The description adds value by disclosing the return fields (file, line, kind, visibility) and the scope (JavaScript and TypeScript files), which helps the agent know what to expect. It does not mention rate limits or edge cases, but those are less critical for a read-only search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is exactly two sentences. The first sentence front-loads the action and scope, the second states the return value. No filler or redundant phrasing; every word contributes to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description adequately explains the return shape (file, line, kind, visibility). It also names the supported languages and the search criterion. Minor omissions like ordering or empty-result behavior are acceptable for a straightforward read-only search tool with full schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, all parameters (path, query, kind, limit) are fully described in the schema. The tool description only lists symbol kinds, which duplicates the already-detailed enum in the schema. It adds no new parameter-level meaning beyond what the schema provides, so it sits at the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb and resource: 'Find functions, classes, interfaces, types, enums, constants, or methods by name across JavaScript and TypeScript files.' It clearly distinguishes itself from siblings like repo_map, file_outline, and entry_points by focusing on symbol search across files, not mapping, outlining, or entry points.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context: use this tool when you need to locate a symbol by its name or fragment. It does not explicitly name alternatives or provide when-not-to-use conditions, but the phrase 'by name' and the focus on definitions makes the intended usage obvious. This is clear context without exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

repo_mapRepository mapA
Read-only

Get a compact map of a repository in one call: filtered file tree, language stats, entry points, and key symbols. Use it before reading files to decide which files matter. Respects .gitignore. Output is capped by a token budget.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the repository root
depthNoHow many directory levels to expand (default 2)
budgetNoApproximate token budget for the response (default 1500)

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, and the description adds non-obvious behavior: it 'Respects .gitignore' and caps output by a token budget. This gives useful operational context beyond the safety annotation without contradicting it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four short sentences front-load the purpose and usage, then add behavioral constraints. No filler or redundant restatement of the tool name; every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only, single-path repository tool with full schema coverage and a safety annotation, the description fully covers output composition, filtering behavior, budget cap, and usage timing. No critical call-time fact is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description reinforces the budget concept but adds little parameter-specific detail beyond the schema's own descriptions of depth and budget.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Get a compact map of a repository') and enumerates the output composition ('filtered file tree, language stats, entry points, and key symbols'), which makes the tool's role distinct from the more targeted sibling tools. The 'in one call' phrasing signals it is the aggregate overview rather than a single-symbol or single-file utility.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly tells the agent when to use it: 'Use it before reading files to decide which files matter.' It does not enumerate alternatives or when-not conditions, so it falls one step short of full routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 4 tool updatesv0.1.0
    • First observedentry_points
    • First observedfile_outline
    • First observedfind_symbol
    • First observedrepo_map

TDQS

A4.2/5.0

Scored across 4 tools

Disambiguation4/5

Each tool targets a distinct concern: repo_map gives a whole-repo overview, find_symbol locates a named symbol across files, file_outline shows one file's structure, and entry_points finds execution starts. There is minor overlap between repo_map and entry_points (both orient you in a repo), but the descriptions make the difference clear.

Naming Consistency4/5

All tool names use a consistent noun-based pattern (repo_map, find_symbol, file_outline, entry_points) with snake_case. The pattern is predictable, though the verbs are not uniform (find vs. implicit get/list), which is a minor deviation.

Tool Count5/5

Four tools is a well-scoped set for a code-navigation/exploration server. Each tool covers a distinct need without redundancy, and the count feels appropriate for the stated purpose.

Completeness4/5

The server covers the main exploration workflow: orient (repo_map, entry_points), locate (find_symbol), and inspect (file_outline). A minor gap is the lack of a tool to read file contents or search by text/pattern, but the server's stated purpose is navigation, not full code retrieval.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides LLM-optimized tools for advanced code analysis, repository complexity evaluation, and call graph generation. It enables users to visualize directory structures, detect code patterns, and build semantic context with significant token savings.
    8 npm
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides coding agents with a mental map of codebases via progressive disclosure, enabling efficient exploration of project structure and entity relationships.
    3
    6 npm
    GPL 3.0
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables coding agents to pre-compute repository structure and access structured intelligence briefs, including dependency graphs, hotspots, and blast radius, reducing token usage and improving code understanding.
    1,668 npm
    1
    -