Tokensafe logo

Tokensafe

Optimizes coding-agent context locally, adds repository security guardrails, and tracks token savings.

Install Tokensafe

Pick your client, then add it in one click or paste the config.

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "tokensafe": {
      "command": "npx",
      "args": [
        "-y",
        "tokensafe"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

npx -y tokensafe

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

tokensafe MCP server narrows coding-agent context to relevant repository code, preserves prompt-cache continuity, and applies local checks to tool calls. It provides repository auditing, architecture mapping, prompt compaction, command sanitization, loop protection, and MCP server management through its CLI and MCP connection. Installation can register it with supported coding agents and add agent-specific hooks or rules. Reach for tokensafe when large codebases, repeated context, unsafe edits, or secret exposure are affecting agent-assisted development.

Use cases

  • Reduce repository context before targeted code changes
  • Audit a repository for secrets and unsafe patterns
  • Trim test output and lockfile noise
  • Map architecture before multi-file edits
  • Monitor token savings across coding-agent sessions

Key features

  • AST-based context reduction
  • Local command and write guardrails
  • Prompt compaction and history folding
  • Repository security and hygiene audits
  • Architecture graph generation
  • Token savings dashboard

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 8d ago via OSV.dev · tokensafe (npm)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars45Stargazers on the source repository.
npm downloads15kPackage downloads in the last 30 days.
Last commit4d agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.

How Tokensafe works

What tokensafe does

tokensafe manages the context and safety boundaries around coding agents working on local repositories. Its context controls can reduce a large source file to the target symbol, type signatures, and nearby dependencies, while other processing trims command output, diffs, lockfile noise, and multi-turn history. The goal is to give an agent the code and terminal information relevant to its current task rather than the entire surrounding repository.

Local guardrails inspect shell commands, file writes, and other tool activity before execution. They target patterns such as fallback credentials, disabled TLS verification, raw SQL interpolation, destructive commands, and accidental .env staging. Large writes can also receive output checks, and local PII or key redaction is part of the protection model.

The package includes a live savings dashboard, repository security auditing, architecture graph generation, prompt-compaction previews, MCP server controls, and a team digest command. It is suited to coding-agent workflows where context volume, repeated retries, or unsafe repository changes need operational controls.

How it works

The local MCP process runs on the developer’s machine and can be launched through npx, the Python package, or the supplied shell installer. An installer detects supported agents, registers the MCP server, injects project rules, and configures lifecycle hooks where the agent supports them.

Context processing uses an AST skeletonizer, an architecture graph, predictive signature prefetch, a diff slicer that removes lockfile noise, a command sanitizer, a test-runner guard, and a repeated-call loop guard. The test guard can force run-once behavior and inspect package.json to identify the runner used by an opaque script.

Remote functionality uses https://api.tokensafe.dev/mcp. Team metrics, managed distillation, shared team cache, and billing use a bearer license key; four public tools can be used without a key.

Setup and configuration

The recommended zero-install setup is:

Terminal
npx tokensafe

Alternatively, install the Python package and start it with pip install tokensafe && tokensafe, or use the macOS/Linux installer:

Terminal
curl -fsSL https://tokensafe.dev/install.sh | bash

A direct MCP registration for Claude Desktop or Cursor is:

config.json
{
  "mcpServers": {
    "tokensafe": { "command": "npx", "args": ["-y", "tokensafe", "mcp"] }
  }
}

Useful local commands include tokensafe stats, tokensafe doctor, tokensafe guard audit, tokensafe test, tokensafe graph, tokensafe mcp disable <server>, tokensafe digest, and tokensafe activate <license-key>.

Tools and capabilities

  • Optimize source context around target functions and nearby dependencies.
  • Compact prompt input and fold multi-turn history.
  • Sanitize terminal output and reduce lockfile or diff noise.
  • Detect repeated tool calls and stop retry loops.
  • Audit repository hygiene and security risks.
  • Map architectural hotspots before multi-file changes.
  • Track measured and estimated token savings in dashboards and digests.
  • Disable configured MCP servers without manually editing JSON.

Limitations and notes

The remote endpoint is separate from the local MCP process and requires a license key for team metrics, managed distillation, shared team cache, and billing. ChatGPT uses the cloud connector rather than a local installation. Agent-specific hooks and automatic loading depend on the client being used.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Tokensafe

tokensafe is an MCP server that connects coding agents to local repositories and exposes tools for context optimization, repository security auditing, architecture mapping, prompt compaction, and MCP server management. It can also connect to TokenSafe’s remote endpoint for team metrics, managed distillation, shared cache, and billing features.

Install it with `npx tokensafe`, `pip install tokensafe && tokensafe`, or the macOS/Linux shell installer. The installer detects supported agents, registers the MCP server, adds project rules, and configures lifecycle hooks where available.

Yes, tokensafe works with Cursor through MCP plus `beforeShellExecution` and `beforeReadFile` hooks. You can let the installer configure it or register `npx -y tokensafe mcp` in Cursor’s MCP configuration.

No, the local MCP server and four public remote tools work without a key. Team metrics, managed distillation, shared team cache, and billing use the remote endpoint with a TokenSafe license key.

Run `tokensafe stats` to open the terminal savings dashboard. It reports total tokens saved, efficiency gain, context traffic, and savings by processing area such as command sanitization, architecture graphs, history folding, and prompt compaction.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewTokensafe AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/tokensafe?style=directory)](https://allmcps.com/mcp/tokensafe)
HTML Embed
<a href="https://allmcps.com/mcp/tokensafe"><img src="https://allmcps.com/api/badge/tokensafe?style=directory" alt="Tokensafe on AllMCPs" /></a>