Skip to main content
Glama

TokenGuard (tokenguard-mcp)

Stop burning AI coding tokens blindly. Zero-dependency CLI & MCP Server that measures repo token costs across Claude / Gemini / GPT / DeepSeek, packs budget-capped context bundles, catches accidental secret leaks, and audits local AI spend.

License: MIT Node.js >= 20


Quick Start (Zero Dependencies)

# 1. Scan any repo for token count, context hogs, and multi-model USD cost
npx tokenguard-mcp scan .

# 2. Pack highest-signal files strictly inside a 24k token budget
npx tokenguard-mcp pack . --budget 24000 --format xml --out context.xml

# 3. Check the cost of your git diff before sending it to an AI reviewer
npx tokenguard-mcp diff --base main

Related MCP server: leantoken

Use as an MCP Server (Claude Code / Cursor / Windsurf / Antigravity)

Add to your MCP config (claude_desktop_config.json, .cursor/mcp.json, or Claude Code MCP settings):

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

Exposed MCP tools:

  • scan_repo_tokens — Inspect token counts, context hogs, and multi-model cost before reading giant files.

  • pack_repo_context — Pack high-signal files within an exact token budget (full free, skeleton Pro).

  • estimate_prompt_cost — Estimate input + output USD cost across 10 major 2026 models.

  • check_repo_budget_and_secrets (Pro) — Enforce token/cost ceilings and catch leaked keys.


Free (MIT Open-Source) vs. Pro ($19 One-Time, No Subscription)

Feature

Free (MIT)

Pro ($19 One-Time)

Repo Token Scanner & Context Hog Finder (scan)

✅

✅

Multi-Model 2026 Cost Estimator (scan, diff, pricing)

✅

✅

Budget-Bounded Context Packer (pack --mode full)

✅

✅

Stdio MCP Server (mcp) for Claude / Cursor / Windsurf

✅

✅

Skeleton Compression (pack --mode skeleton, 60–85% token savings)

—

✅

CI Budget Gate + Secret Leak Scanner (check --format sarif)

—

✅

Local AI Spend Ledger & Session Audit (audit)

—

✅

Lifetime updates + CI env var support (TOKENGUARD_LICENSE_KEY)

—

✅

👉 Get TokenGuard Pro ($19 one-time): https://www.creem.io/product/prod_T2ytVQvgiLAWMMxLKnTXU

tokenguard activate <YOUR_CREEM_LICENSE_KEY>

Privacy & Security

  • 100% local execution: your source code, git diffs, and session logs never leave your machine.

  • Secret scan results automatically redact detected keys (AKIAIO...MPLE) so secrets are never echoed into CI logs.

  • Zero external runtime npm dependencies.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Local-first code intelligence MCP server that enables coding agents to search code, inspect structure, read exact ranges, and explore Git history with explicit token budgets.
      171
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables local-first tracking of AI token usage and costs from Claude Code and OpenCode, answering queries about tokens, models, sessions, and cost through MCP tools and a CLI, with no network calls.
      704 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables local LLM tools and agentic IDEs to inspect repository token maps, retrieve clean token-bounded codebase snapshots, and audit code for hardcoded secrets via MCP over stdio.
      4
      MIT