# LeanToken

Narrows a repository down to the files and code an agent actually needs, and keeps every response inside a token budget.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 124
- Author: morluto
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/morluto/leantoken
- Updated: 2026-10-19
- HTML: https://affpapa.org/en/nevibecode/mcp/leantoken

## What it does

LeanToken indexes your source into a local database on your machine and acts as a read-only discovery and retrieval layer. The agent asks it for context; edits, builds and tests stay with the host's normal tools.

Every response carries an explicit token limit, so one large file can't swallow the request. The toolset covers file lookup, code search, structure outlines, exact range reads, history, JSON queries and token accounting. To avoid paying twice for the same evidence, the next `context` call accepts the previous `receipt_id` or returned fragment hashes as `known_hashes`.

Setup runs through `npx leantoken setup`: the wizard preselects the clients it detects, shows the config paths and asks for a separate confirmation. If a host starts LeanToken from the home directory or a filesystem root, it refuses to index that broad root by default. Verify the connection and a first retrieval with `npx leantoken doctor`.

## Install

### Claude Code (native platform)

**Install**
- The MCP registry has no launch command for it: see the repository README

## When to use it
- find the relevant code in a large repo without reading all of it
- keep an agent's output inside a token limit
- continue a task without resending the same source
- trace an observed failure from its traces and paths
- inspect a module's structure before editing

## Example prompts
- Investigate this failure: here are the traces, paths and symbols.
- Review the change from `BASE..HEAD`, changed paths only.

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

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