LeanToken MCP

Local code search for agents: finds the files and fragments that matter and keeps context within a set token budget

  • 158 ★ on the repository
  • Last commit
  • Apache-2.0
MCP server

Minimal access

Why this level

  • The local index database stores source fragments on disk
  • The `setup` command edits client configs, so review the shown path list before it writes
All reasons and checks

morluto/leantoken

Install

Manual install

npx leantoken setup

Detects clients, shows config edits and asks for confirmation.

Access and checks

How we review

Minimal accessThe tool runs nothing and makes no network calls.

  • The local index database stores source fragments on disk
  • The `setup` command edits client configs, so review the shown path list before it writes

This is third-party code. Review the repository files before installing.

What it does

LeanToken indexes source code on your machine in a local database and gives the agent size-bounded answers. There are nine tools: `leantoken.context` for a first broad look at a task, `leantoken.search` instead of grep, `leantoken.files` instead of find, `leantoken.outline` for signatures and imports without reading a whole file, `leantoken.read` for one symbol or a line range, `leantoken.history` for differences between Git revisions, `leantoken.json` for JSON queries, `leantoken.receipt_rebase` and `leantoken.savings`. Every response has an explicit token limit, so a big file does not take over the whole request. The Rust server is read-only, and edits, builds and tests stay with the agent's usual tools. Installation is done with `npx leantoken setup`, which configures Claude Code, Cursor, OpenCode, Codex, Gemini CLI or Antigravity and installs a small hint skill. In a controlled 60-run study input token use fell by 20.1 percent with limited repository exploration and by 37.6 percent with broad exploration.

Who it is for. Developers of large repositories who run an agent over code and want to cut token use and context noise.

Good fit when

  • The task is broad, for example about request cancellation, and the agent first gets material through `leantoken.context`
  • You need a module's signatures and imports without reading a file of thousands of lines
  • You need to trace how a symbol changed between Git revisions without reading the whole diff
  • Token bills grow and `npx leantoken savings` shows what was actually saved

Not a fit when

  • You need code edits or test runs: the server only reads the repository
  • The repository is tiny: the agent's built-in search and read are plenty
  • You need a cloud index without a local database: the index is built and stored on your machine

Example request

Find the code related to request cancellation, show the signatures of the affected modules and cap the answer at three thousand tokens

MCP

Transport
stdio
Authentication
not required

Limitations

The host must start the server from the project working directory: if it starts from the home directory or filesystem root, LeanToken refuses to index such a broad root by default. By default a response takes the last completed index generation and does not wait for disk changes, and fresh edits need `consistency: "reconcile_working_tree"`. Results of the 60-run study are described in the methodology and savings depend on the task and repository. Before writing config, `setup` asks for a separate confirmation and pins the version. The license is MIT or Apache 2.0 and Rust 1.95 is needed only when building from source.

How to disable. Remove the `leantoken` entry from client configs (`claude mcp remove leantoken`) and the hint skill that `setup` added, and unpin the version if you want.

FAQ

How do I connect LeanToken?

With `npx leantoken setup`: it detects supported clients, shows config paths and asks for confirmation. For automation name clients explicitly, for example `--claude --codex --yes`.

Which tools does the server have?

Nine: `context`, `search`, `files`, `outline`, `read`, `history`, `json`, `receipt_rebase` and `savings` with the `leantoken.` prefix. The catalog is small on purpose so descriptions do not eat context.

Does LeanToken change my files?

No, it is a search and read layer. Edits, builds and tests stay with the agent's usual tools.

How do I check that savings exist?

With `npx leantoken savings`: it shows repository token accounting, hash suppression and observation limits. The measurement methodology is in `docs/measurement.md`.

Where does my source go?

Nowhere: indexing is local and the database sits on your machine. Network access is needed only to download the package.

Discussion

No questions or reviews yet.

Local dashboard for tokens, cost and tool calls across Claude Code, Codex, Gemini CLI and many other coding agents.

CLIExtended access387Repository stars

A local code graph answers agent questions about symbols and callers, so they reread whole files far less often.

CLIExtended access86Repository stars

A code knowledge graph for your agent: callers, dependents and blast radius over MCP instead of reading files

MCP serverExtended access222Repository stars

Local code search for Claude Code and Codex: six fast tools in place of grep and Read, with an index that updates itself.

CLIExtended access120Repository stars

CLI that builds a codebase index and a 250-token map so an agent does not read hundreds of files to find the right one.

CLIExtended access131Repository stars

A local MCP server that indexes your code so the agent pulls the functions it needs instead of rereading whole files

MCP serverExtended access457Repository stars

README in short

A headline promising token savings, a 60-run study, a `setup` and `doctor` quick start, detailed notes on install safety and three core traits: local, explicit token budgets, built for agents. Then come a tool table, advanced controls and docs.

README badge

Report a problem