Leantoken

Code intelligence for agents: find the code that matters and keep your context window and tokens lean.

LLM Mart 0 views 3 listing impressions

Code intelligence for agents: find the code that matters and keep your context window and tokens lean.

Language: English · 简体中文 · 日本語 · 한국어

  • MCP Registry name: mcp-name: io.github.morluto/leantoken
LeanToken narrowing a large codebase to the files and code an AI agent needs

npm npm downloads Rust 1.95+ License: MIT OR Apache-2.0

Install · Why LeanToken · Tools · CLI · How it works · Docs


Measured token savings: In a controlled 60-run study, LeanToken used 20.1% fewer model input tokens than the agent's built-in tools with limited repository exploration, and 37.6% fewer than those tools with broad exploration. See exactly how it was measured in the measurement methodology.

Quick start

Add LeanToken to Claude Code, Cursor, OpenCode, Codex, Gemini CLI, or Antigravity:

npx leantoken setup
Setup behavior and safety

Current releases stop setup before writing when npx resolves a stale project-local or ancestor install, and point to npx leantoken@latest setup. Older releases that predate this check can be bootstrapped directly with that versioned command.

The interactive setup wizard preselects supported clients it detects; you can change that selection before continuing. It then shows the exact configuration paths and MCP launcher and asks for a separate final confirmation. Automation never treats detection as consent. An npx-based setup pins the exact LeanToken version that ran setup, so restarting a client cannot silently move to a newer release.

Global setup never stores the repository where setup happened. OpenCode gets a workspace-relative working directory; other supported clients launch LeanToken from the workspace cwd selected by the host. If a host instead starts it from the home directory or a filesystem root, LeanToken refuses to index that broad root by default.

Restart or reload the configured clients, then verify the connection and first retrieval from a repository:

npx leantoken doctor

Try a broad task such as: Find the code related to request cancellation before editing. LeanToken helps the agent start with leantoken.context, while its normal tools remain available for edits, builds, and tests.

Inspect LeanToken's observed repository-local token accounting:

npx leantoken savings
Local by default

Source is indexed on your machine in a local database. LeanToken is a read-only discovery and retrieval layer.
Explicit token budgets

Every response has an explicit token limit, so large files cannot take over the request.
Built for agent workflows

Find files, search code, inspect structure, read exact ranges, trace history, query JSON, and track token usage through focused tools.
Advanced setup and version management

To skip the wizard, select clients explicitly or configure all supported clients:

npx leantoken setup --claude --codex --yes
npx leantoken setup --all --yes

From the project's README.