TokenSafe
Your AI agent is smart enough to code all day. Local firewall & zero-loss runtime.
At a glance
Not tested yet- GitHub stars
- 47
- Weekly downloads
- 11,670
- Last commit
- 2026-11-19
- Licence
- MIT
- Transport
- stdio
- Auth
- none
npx -y tokensafe
What it does
TokenSafe is a local MCP server that filters the context an AI coding agent sees. It trims file reads, terminal output, diffs and session history down to what the model needs, and it checks writes and shell commands for secrets and unsafe patterns before they run. It is aimed at developers and teams using coding agents such as Cursor, Claude Code, Codex, Windsurf, Google Antigravity, Kimi Code and ChatGPT.
Tools it gives your agent
scoped_search: SQLite full-text search with trigram tokenization and BM25 relevance ranking across the repository.optimize_image: scales down oversized screenshots, diagrams and mockups over 1024px, keeping original files intact.get_mistakes: persistent project memory of failed hypotheses, loop guard trips and git reverts.prune_superseded: prunes obsolete intermediate tool reads that later edits or re-reads superseded.expand_ref: recovers a folded block through a reversible 8-char hash anchor.get_architecture_graph: maps dependency centrality, import hubs and critical call paths.smart_read_file: slices code so the agent reads target logic instead of whole modules.
Quick start
Run the installer, which detects the agents on your machine, registers the MCP server, injects project rules and wires lifecycle hooks where supported.
npx tokensafe
Then check your environment and view savings.
tokensafe doctor
tokensafe stats
Add it to Claude Code from a terminal:
claude mcp add tokensafe -- npx -y tokensafe
Or add this to .mcp.json in your project root (Claude Code) or .cursor/mcp.json (Cursor):
{
"mcpServers": {
"tokensafe": {
"command": "npx",
"args": [
"-y",
"tokensafe"
]
}
}
}Environment variables
The registry entry declares no environment variables.
Example prompts
- "Map the architecture hotspots in this repo before I change the auth module."
- "Find where the validate_token function is defined and show me its callers."
- "This screenshot is too large. Downscale it before you look at it."
- "Have we already tried a fix for this failing test? Check the mistakes ledger."
What to watch out for
- Cloud features (team metrics, managed distillation, shared team cache, billing) run on the remote endpoint
https://api.tokensafe.dev/mcpand need aTS2.license key. Four public tools work without a key. - A Team Trial is 7 days free. A seat is listed at $29.
- TokenSafe Guard blocks writes and shell commands it judges unsafe, so some edits and commands will be refused.
- The test-runner guard forces run-once mode (
CI=true,--watch=false,--forceExit).
Not tested by tools4agents yet. Read the source repository before you install it.
Similar tools
Everything
The official test server. Exercises every part of the protocol, so it is the fastest way to check your setup works at all.
Filesystem
Gives an agent scoped read and write access to directories you name explicitly. The usual first MCP server people install.
Git
Read, search, and manipulate local Git repositories. Lets an agent inspect history and diffs without shelling out.
Sequential Thinking
Gives a model a scratchpad for multi step reasoning, letting it revise earlier steps instead of committing to a first answer.