Skip to main content
Glama

tokens-saver-mcp

A provider-agnostic MCP (Model Context Protocol) server that routes 7 narrow text-processing tools to budget models — local or cloud — to reduce main model token consumption.

Core idea: offload low-risk, structured, short-output sub-tasks (classification, extraction, summarization, rewriting, small code generation) to cheaper models, keeping complex reasoning and high-risk changes on Claude/GPT.

Tools

Tool

Purpose

tsm_classify

Classify text into a given label set

tsm_extract_json

Extract structured fields from long text

tsm_summarize

Compress long text to a short summary

tsm_rewrite

Rewrite text in a different style (or translate zh↔en)

tsm_codegen_small_patch

Generate small code snippets / function-level patches

tsm_diff_digest

Compress a git diff into a structured change summary

tsm_task_extract

Extract actionable tasks from unstructured text

All tools return both human-readable content and machine-consumable structuredContent.

Related MCP server: ai-workers-mcp

Requirements

  • Node.js >= 20

  • A running provider (local model or cloud API with OpenAI-compatible endpoint)

Setup

npm install
npm run build

Create ~/.tokens-saver-mcp/settings.json to configure providers (see below).
If the file does not exist, the server falls back to a built-in default pointing at http://127.0.0.1:1234 with zai-org/glm-4.7-flash.

Configuration

~/.tokens-saver-mcp/settings.json

{
  "defaultProvider": "remote_budget_cn",
  "providers": {
    "local": {
      "type": "openai_compatible",
      "baseUrl": "http://127.0.0.1:11434/v1",
      "apiKeyEnv": "",
      "model": "qwen2.5:14b",
      "timeoutMs": 15000,
      "maxRetries": 1,
      "temperature": 0.1
    },
    "remote_budget_cn": {
      "type": "openai_compatible",
      "baseUrl": "https://api.minimax.chat/compatible-mode/v1",
      "apiKeyEnv": "MINIMAX_API_KEY",
      "model": "MiniMax-M2.7",
      "timeoutMs": 20000,
      "maxRetries": 2,
      "temperature": 0.2
    }
  },
  "toolRouting": {
    "tsm_classify": "local",
    "tsm_extract_json": "remote_budget_cn",
    "tsm_summarize": "remote_budget_cn",
    "tsm_rewrite": "remote_budget_cn",
    "tsm_codegen_small_patch": "remote_budget_cn",
    "tsm_diff_digest": "remote_budget_cn",
    "tsm_task_extract": "local"
  }
}

Key rules:

  • API keys are never stored in the config file. Set apiKeyEnv to the environment variable name that holds the key.

  • For local providers with no auth, set apiKeyEnv to "".

  • toolRouting is optional — unrouted tools fall back to defaultProvider.

Usage

# Run as MCP server (stdio transport)
npm start

Claude Code integration

{
  "mcpServers": {
    "tokens-saver": {
      "command": "node",
      "args": ["/path/to/tokens-saver-mcp/dist/server.js"]
    }
  }
}

Development

npm test          # Run 61 tests
npm run typecheck # Type check only
npm run build     # Compile TypeScript

Available Tools

7 tools
tsm_classifyA

Classify text into one of the provided labels using a budget model. Returns label, confidence score, and a brief reason. Useful for intent classification, routing decisions, and tagging.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesText to classify
labelsYesList of possible labels
instructionsNoOptional classification instructions

TDQS

A4/5.0
Behavior3/5

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

No annotations provided, so description must disclose behavior. It mentions budget model, returns label/confidence/reason, but lacks edge cases, limitations, or state effects.

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 concise sentences: first explains action and output, second lists use cases. No wasted words.

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 3-param tool without output schema, description adequately covers functionality and output shape but could include confidence scale or label limits.

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%, baseline 3. Description adds minimal extra meaning beyond the schema's parameter descriptions.

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 clearly states the action (classify text), the resource (text), and specifies it uses a budget model, distinguishing it from sibling tools like summarize or extract.

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 provides explicit use cases (intent classification, routing, tagging) but does not mention when not to use or alternatives.

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

tsm_codegen_small_patchA

Generate small code snippets or function-level patches using a budget model. Scoped to single functions, regex, SQL, scripts, or unit test samples. NOT for multi-file or architectural designs.

ParametersJSON Schema
NameRequiredDescriptionDefault
taskYesDescription of what the code snippet should do
languageNoTarget programming language
constraintsNoAdditional constraints or requirements
existing_codeNoExisting code context for the patch

TDQS

A3.9/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden. It mentions the use of a 'budget model' and scoping to single functions, but does not disclose auth requirements, rate limits, error handling, or behavior when input exceeds scope. Adequate but lacking depth.

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?

Extremely concise: two sentences total. First sentence states main purpose, second sets clear exclusions. Zero wasted words, front-loaded with essential information.

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

Completeness3/5

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

Given no output schema, no annotations, and 4 parameters with brief descriptions, the tool description covers purpose and scope minimally. It lacks details on return format, error states, or behavior for edge cases. Adequate for a simple tool but not comprehensive.

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 baseline is 3. The description adds marginal value beyond the schema: it provides context about scope (single functions) but does not enhance individual parameter meanings. The schema descriptions are basic, and the tool description does not enrich them.

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?

Description clearly states the tool generates small code snippets or function-level patches using a budget model. It specifies scope (single functions, regex, SQL, scripts, unit tests) and explicitly excludes multi-file or architectural designs, distinguishing it from sibling tools like tsm_rewrite or tsm_summarize.

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?

Description explicitly says NOT for multi-file or architectural designs, providing clear when-not-to-use guidance. However, it does not directly name alternative tools for such cases, though the sibling list is available. Implicitly suggests use for small, focused code generation tasks.

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

tsm_diff_digestA

Compress a git diff into a structured summary of changed areas, behavior changes, risks, and a one-paragraph overview. Helps the main model quickly understand large diffs.

ParametersJSON Schema
NameRequiredDescriptionDefault
focusNoAnalysis focus: behavior changes, risks, or general summary
diff_textYesGit diff or patch text to analyze

TDQS

A3.8/5.0
Behavior2/5

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

No annotations provided; description does not disclose behavioral traits such as whether the tool is read-only, destructive, or requires any permissions. It only describes the output without clarifying side effects or constraints, leaving a gap for an agent.

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, no redundant information. First sentence states core function and output, second sentence provides use case. Economical and clear.

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?

No output schema, but description outlines the kind of output (structured summary with specific components). For a tool with 2 parameters and no nested objects, this is fairly complete. Could be improved with more specific output format details.

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 baseline is 3. Description adds marginal value by linking the focus enum options to the output components ('behavior changes, risks' correspond to enum values). No further parameter details beyond schema.

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?

Description clearly states verb 'compress' and resource 'git diff', and specifies output includes 'structured summary of changed areas, behavior changes, risks, and a one-paragraph overview'. Differentiates from siblings like tsm_summarize or tsm_classify by being specific to git diffs.

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?

Description says 'Helps the main model quickly understand large diffs', which implies usage context. However, no explicit when-not or alternatives to sibling tools are provided, but the specificity of the tool name and description makes the use case clear.

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

tsm_extract_jsonA

Extract structured fields from long text according to a schema description. Returns a JSON object with extracted data and a list of missing fields. Useful for parsing documents, issues, logs.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesSource text to extract data from
extraction_goalYesWhat extraction goal or use case
schema_descriptionYesDescription of the fields to extract

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries full burden. It mentions the return format (JSON object with extracted data and missing fields), which adds value beyond the schema. However, it does not disclose potential errors, side effects, or limitations.

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 very concise with two sentences: first stating the core purpose, then mentioning return and use cases. No unnecessary words.

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 the absence of an output schema, the description adequately covers the return format. It explains the tool's role in extraction tasks but could include more about safety or common pitfalls.

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%, providing clear parameter descriptions. The tool description adds minimal extra meaning beyond the schema, only connecting the schema_description parameter to the extraction task.

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 clearly states the tool extracts structured fields from long text according to a schema description, specifying the verb and resource. It distinguishes from sibling tools like tsm_classify (classification) and tsm_summarize (summarization) by focusing on extraction.

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 provides context with examples ('useful for parsing documents, issues, logs'), implying when to use it. However, it lacks explicit guidance on when not to use it or alternative tools for similar tasks.

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

tsm_rewriteA

Rewrite text in a different style (concise, formal, technical, friendly, or translate between Chinese and English) without changing the core facts.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesText to rewrite
styleYesTarget rewriting style
constraintsNoOptional additional constraints for rewriting

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden. It states the behavioral guarantee 'without changing the core facts' and lists the available styles. However, it does not disclose other traits like whether it is read-only, any rate limits, or output format. The guarantee is useful but incomplete for full transparency.

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 a single sentence with a parenthetical list of styles. It is concise with zero wasted words, front-loading the core purpose and key details efficiently.

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 explains the tool transforms text style and preserves facts, which is fairly complete for a simple rewriting tool. It covers the key operations and highlights translation capabilities. Minor omission: no mention of output format, but it is implicitly the rewritten text.

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% with descriptions for all three parameters. The description restates the style enum but adds no new meaning beyond the schema's property descriptions. For high coverage, baseline is 3, and the description does not elevate beyond that.

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 clearly states the verb 'Rewrite', the resource 'text', and the action 'in a different style' while preserving core facts. It distinguishes itself from sibling tools like tsm_classify and tsm_summarize by focusing on style transformation rather than classification or summarization.

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

Usage Guidelines3/5

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

The description provides a list of styles (concise, formal, technical, friendly, translation) implying usage for style changes only. However, it lacks explicit guidance on when to use versus alternatives, such as not to use for summarization or classification. The sibling tools are distinct enough that context is implied, but not explicitly stated.

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

tsm_summarizeB

Compress long text into a concise summary with bullet points and risk flags. Useful for compressing long conversations, logs, documents, or diff context before passing to the main model.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesLong text to summarize
max_pointsNoMaximum number of bullet points (default: 6)
summary_styleYesSummarization style: brief paragraph, bullet points, or decision-focused

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description must disclose all behavioral traits. It mentions 'risk flags' which are not reflected in the input schema, leaving output behavior unclear. It does not state whether the tool is read-only or has side effects.

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 extremely concise: one sentence front-loaded with the core purpose. Every part is informative and earns its place. No fluff or redundancy.

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

Completeness2/5

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

The tool has no output schema and the description does not explain the return format, error conditions, or limitations. It mentions 'bullet points and risk flags' but provides no detail on how they are structured, leaving the agent underinformed.

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%, so the baseline is 3. The description adds context about 'risk flags' but does not significantly enhance understanding beyond the schema's parameter descriptions. It adds minimal value.

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

Purpose4/5

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

The description clearly states the tool compresses long text into a concise summary with bullet points and risk flags. It distinguishes from sibling tools like classification and code generation. However, 'risk flags' are not defined in the schema, causing slight ambiguity.

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

Usage Guidelines3/5

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

The description provides examples of when to use the tool ('long conversations, logs, documents, or diff context'), but does not specify when not to use it or guide toward alternative tools. The usage context is implied but lacks explicit exclusions.

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

tsm_task_extractB

Extract an actionable task list from unstructured text (meeting notes, daily reports, requirements). Returns tasks with optional owner, due date, status, and notes.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesSource text to extract tasks from
task_granularityYesLevel of task granularity: coarse (high-level), normal, or fine (atomic steps)

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description must convey behavioral traits. It states the tool returns tasks with optional fields, but does not clarify if it is read-only, what side effects exist, or any authorization needs. The non-destructive nature is implied but not explicit.

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 two sentences, front-loaded with the main action, and contains no irrelevant information. Every word earns its place.

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

Completeness3/5

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

For a simple 2-parameter tool with no output schema, the description covers purpose and input but lacks details on error handling, input limits, or exhaustive output structure. It is adequate but not comprehensive.

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%, so the baseline is 3. The description adds output structure context (owner, due date, etc.) but does not enhance parameter understanding (e.g., when to choose coarse vs fine granularity).

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 clearly states the tool extracts actionable task lists from unstructured text, with specific examples (meeting notes, daily reports, requirements). The verb 'extract' and resource 'task list' are specific, and it differentiates well from siblings like tsm_classify or tsm_extract_json.

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

Usage Guidelines2/5

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

The description lists example input types but provides no explicit guidance on when to use this tool versus alternatives (e.g., tsm_extract_json) or when not to use it. No exclusion criteria or context for sibling comparison.

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. 7 tool updatesv0.1.0
    • First observedtsm_classify
    • First observedtsm_codegen_small_patch
    • First observedtsm_diff_digest
    • First observedtsm_extract_json
    • First observedtsm_rewrite
    • First observedtsm_summarize
    • First observedtsm_task_extract

TDQS

A3.8/5.0

Scored across 7 tools

Disambiguation5/5

Each tool has a distinct, non-overlapping purpose: classification, code patch generation, diff summarization, JSON extraction, rewriting, text summarization, and task extraction. No ambiguity between tools.

Naming Consistency4/5

All tools use the 'tsm_' prefix and snake_case. Most follow a verb_noun pattern (classify, summarize, rewrite), though 'tsm_codegen_small_patch' is slightly less consistent with its compound noun. Overall, naming is clear and predictable.

Tool Count5/5

With 7 tools, the server is well-scoped for a utility focused on token-saving and text processing. Each tool addresses a common need without being excessive or insufficient.

Completeness4/5

The tool set covers major text operations: classification, extraction, transformation, and summarization. Minor gaps exist (e.g., no data masking or bulk processing), but the core functionality for offloading to budget models is complete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers