Skip to main content

Nuke your token usage. Intelligent code indexer with O(1) symbol retrieval, hybrid search, and call graph analysis.

Project description

TokenNuke

Nuke your token usage. Intelligent code indexer MCP server with O(1) symbol retrieval, hybrid search, and call graph analysis.

TokenNuke indexes your codebase using tree-sitter, extracts every function, class, method, constant, and type with byte offsets, then serves them to AI agents via MCP. Instead of reading entire files, agents retrieve exactly the symbols they need — saving 80-95% of tokens.

Features

  • O(1) Symbol Retrieval — Byte-offset reads. No file scanning.
  • 10 Languages — Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby
  • Hybrid Search — FTS5 keyword search + vector embeddings via Reciprocal Rank Fusion
  • Call Graph — Trace "who calls this?" and "what does this call?" with depth traversal
  • Incremental Indexing — SHA-256 per file. Only re-indexes what changed.
  • Full-Text Search — Search raw file contents (strings, comments, config values)
  • No File Limit — SQLite backend, not JSON. Index repos with 100K+ files.
  • Dual Transport — stdio (local) or streamable-http (remote)
  • Security — Path traversal protection, secret file detection, binary filtering

Install

pip install tokennuke

Quick Start

Claude Code / Claude Desktop

Add to your MCP config (~/.claude.json or claude_desktop_config.json):

{
  "mcpServers": {
    "tokennuke": {
      "command": "tokennuke",
      "args": []
    }
  }
}

CLI

# Start in stdio mode (default)
tokennuke

# Start as HTTP server
tokennuke --transport streamable-http --port 5100

13 MCP Tools

Tool Description
index_folder Index a local directory
index_repo Clone and index a Git repo (GitHub/GitLab/Bitbucket)
list_repos List all indexed repositories
invalidate_cache Force full re-index
file_tree Directory tree with file counts
file_outline All symbols in a single file
repo_outline All symbols in repo (summary)
get_symbol Full source of one symbol (O(1) byte seek)
get_symbols Batch get multiple symbols
search_symbols Hybrid FTS5 + vector search
search_text Full-text search in file contents
get_callees What does this function call?
get_callers Who calls this function?

How It Works

  1. Index: Tree-sitter parses source files into ASTs. We walk each AST extracting symbols (functions, classes, methods, constants, types) with their exact byte offsets.
  2. Store: Symbols go into per-repo SQLite databases with FTS5 indexes and sqlite-vec embeddings.
  3. Search: Hybrid search combines BM25 keyword matching with semantic vector similarity via Reciprocal Rank Fusion.
  4. Retrieve: get_symbol seeks to the exact byte offset in the source file and reads only that symbol's bytes. No wasted tokens.
  5. Graph: Call expressions are extracted from function bodies and stored as edges. Callee names are resolved to symbol IDs after indexing.

Token Savings Example

Method Tokens Savings
Read entire file (500 lines) ~4,000
file_outline + get_symbol ~200-400 90-95%

Development

git clone https://github.com/BigJai/tokennuke
cd tokennuke
pip install -e ".[dev]"
pytest tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokennuke-0.1.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokennuke-0.1.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file tokennuke-0.1.0.tar.gz.

File metadata

  • Download URL: tokennuke-0.1.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tokennuke-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cffc9128537e136ee3e6ce424227873a144c2abcac87809980cdb460c8bc8f18
MD5 891c288d0cfb3420989864667bbcca9f
BLAKE2b-256 31eb6f0ad513723886fc96ea4f4ce1d6219ccbb18916d8c6e52f9ccc767899d8

See more details on using hashes here.

File details

Details for the file tokennuke-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tokennuke-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tokennuke-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1deeee89f48ac8cfd32518f289d1a854b063699725094c088bddb9aba838956
MD5 242ccfcd74cee578726a824a51ad93df
BLAKE2b-256 ca448beb3561ee4487b149c4662cf9774a5981cd2cb3b5821ca2216e54cd096f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page