# TokenSafe

The TokenSafe MCP server for Claude Code trims irrelevant material from an AI agent’s working context. It narrows code snippets and cleans tool output during coding sessions.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 47 repo stars
- Author: tokensafe-dev
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/tokensafe-dev/tokensafe
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — warning: a command downloads a script from tokensafe.dev and runs it right away. Do not run such commands without an explicit yes from the human.
- HTML: https://affpapa.org/en/nevibecode/mcp/tokensafe-dev-tokensafe

## What it does

TokenSafe uses Tree-sitter to select code fragments, searches the repository, and removes outdated tool results from long transcripts. It also strips terminal control sequences and resizes images before they reach the model. Image handling uses Pillow or macOS `sips`.

The local `npx` setup runs basic tools without a key. Cloud features such as team metrics, a shared team cache, and managed distillation connect to `https://api.tokensafe.dev/mcp` and require a TS2 license key. The Claude Code HTTP setup registers the cloud server; a separate local command runs TokenSafe through `npx`.

## Requirements
- Needs: Node.js (commands run via npx)
- Remote server: `https://api.tokensafe.dev/mcp`

## Install

### Claude Code (native platform)

1. **Platform CLI: remote server**
```bash
claude mcp add --transport http tokensafe https://api.tokensafe.dev/mcp
```

2. **Platform CLI**
```bash
claude mcp add tokensafe-dev-tokensafe -- npx -y tokensafe
```

### Codex

1. **Platform CLI: remote server**
```bash
codex mcp add tokensafe-dev-tokensafe --url https://api.tokensafe.dev/mcp
```

2. **Platform CLI**
```bash
codex mcp add tokensafe-dev-tokensafe -- npx -y tokensafe
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "tokensafe-dev-tokensafe": {
            "url": "https://api.tokensafe.dev/mcp"
        }
    }
}
```
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "tokensafe-dev-tokensafe": {
            "command": "npx",
            "args": [
                "-y",
                "tokensafe"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "tokensafe-dev-tokensafe": {
            "type": "http",
            "url": "https://api.tokensafe.dev/mcp"
        }
    }
}
```
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "tokensafe-dev-tokensafe": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "tokensafe"
            ]
        }
    }
}
```

### Gemini CLI

1. **Platform CLI: remote server**
```bash
gemini mcp add -t http tokensafe-dev-tokensafe https://api.tokensafe.dev/mcp
```

2. **Platform CLI**
```bash
gemini mcp add tokensafe-dev-tokensafe npx -y tokensafe
```

## When to use it
- trim lockfiles and build output from an agent’s context
- locate API calls and their corresponding server routes
- remove superseded tool results from long session transcripts
- strip ANSI control codes from command output

## Example prompts
- Keep only the code fragments relevant to this session.
- Find the client API calls and matching server routes in this repository.
- Remove terminal control sequences from the test output.

## Similar
- [codegraph](https://affpapa.org/en/nevibecode/skills/codegraph.md) — skill · 891 installs
- [grepai-languages](https://affpapa.org/en/nevibecode/skills/grepai-languages.md) — skill · 742 installs
- [jcodemunch-mcp-code-retrieval](https://affpapa.org/en/nevibecode/skills/jcodemunch-mcp-code-retrieval.md) — skill · 230 installs
- [codedb-mcp-fast-code-intelligence](https://affpapa.org/en/nevibecode/skills/codedb-mcp-fast-code-intelligence.md) — skill · 116 installs
- [jCodemunch MCP](https://affpapa.org/en/nevibecode/mcp/jcodemunch-mcp.md) — MCP server · ★ 2857 repo stars
- [Octocode](https://affpapa.org/en/nevibecode/mcp/octocode.md) — MCP server · ★ 529 repo stars

## Other versions with the same name
- [TokenSafe · ](https://affpapa.org/en/nevibecode/mcp/tokensafe.md) — 697 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
