# tokensafe [Health: Active]

**Category:** 🤖 Coding Agents  
**Repository:** https://github.com/tokensafe-dev/tokensafe  
**GitHub Stars:** 47  
**npm Downloads (last month):** 21828  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/tokensafe

## Description
Reduce your AI bills by up to 99%. Your agents read only needed code, keep prompt caches intact across turns, and keep secrets out of git.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "tokensafe": {
    "command": "npx",
    "args": ["-y","tokensafe"]
  }
}
```

## Documentation

## 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:

```bash
npx tokensafe
```

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

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

A direct MCP registration for Claude Desktop or Cursor is:

```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.

_Full upstream README: https://allmcps.com/mcp/tokensafe/readme_

