MT

mauriziofonte/toktoken

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

59 stars 10 forks 质量 66 趋势 13AGPL-3.0

TokToken 是一款快速的单二进制 C 代码库索引器,用于 AI 编码代理。它由 universal-ctags 和 SQLite FTS5 驱动,提供精确的符号搜索、依赖追踪和 MCP 服务器。

概览

现在,你的AI编码代理。这浪费了代币、金钱和上下文窗口。. 来自 Redis 的实数(727 个文件,45K 符号,索引时间为 0.9 秒): 扩展性很好。在Linux内核(65K文件,740万符号)索引中,大约170秒内查看: 一个命令索引你的代码库。你的代理会搜索符号、跟踪导入,并且每次操作只获取它需要的代码。 可支持 Claude Code、Cursor、Windsurf、Copilot、Gemini、Codex 等等。单一二进制,零依赖,项目内无任何内容。 告诉你的AI代理读取文档/LLM.md——它会几乎自动安装和配置TokToken。至于你们这些人类,继续阅读。 - 通过 universal-ctags + 16 个自定义解析器(参见文档/语言)。

概述(AI 翻译)

现在,你的AI编码代理会读取整个文件只为找到一个函数。这浪费了token、金钱和上下文窗口。TokToken解决了这个问题。

来自 Redis 的实数(727 个文件,45K 符号,索引时间为 0.9 秒):

你的经纪人需要什么 没有TokToken的 有TokToken的 节省
initServer() 在 server.c(8141行)中 84,193 个令牌 2,699 个令牌 97%
sdslen() 在 sds.h (340行) 2,678 个令牌 132 个令牌 95%
processCommand() 在 server.c 84,193 个令牌 4,412 个令牌 95%
[redisCommandProc typedef 在 server.h(4503行) 56,754个令牌 50 个令牌 99%

TokToken 扩展性很好。在 Linux 内核(65K 文件,740 万符号)索引中,大约 170 秒内检查:

你的经纪人需要什么 没有TokToken的 有TokToken的 节省
__schedule() 在 kernel/sched/core.c (10961行) 73,084 个令牌 1,335 个令牌 98%
do_sys_open() 在 fs/open.c(1583行)中 9,915个令牌 89个令牌 99%
kmalloc() 在 'include/linux/slab.

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

TokToken (beta release)

Right now, your AI coding agent reads entire files just to find one function. That wastes tokens, money, and context window. TokToken fixes this.

Real numbers from Redis (727 files, 45K symbols, indexed in 0.9s):

What your agent needs Without TokToken With TokToken Savings
initServer() in server.c (8141 lines) 84,193 tokens 2,699 tokens 97%
sdslen() in sds.h (340 lines) 2,678 tokens 132 tokens 95%
processCommand() in server.c 84,193 tokens 4,412 tokens 95%
redisCommandProc typedef in server.h (4503 lines) 56,754 tokens 50 tokens 99%

TokToken scales well. Check it on the Linux kernel (65K files, 7.4M symbols) indexes in ~170 seconds:

What your agent needs Without TokToken With TokToken Savings
__schedule() in kernel/sched/core.c (10961 lines) 73,084 tokens 1,335 tokens 98%
do_sys_open() in fs/open.c (1583 lines) 9,915 tokens 89 tokens 99%
kmalloc() in include/linux/slab.h (1280 lines) 11,272 tokens 1,372 tokens 88%
ext4_fill_super() in fs/ext4/super.c (7573 lines) 53,651 tokens 376 tokens 99%

One command indexes your codebase. Your agent searches symbols, traces imports, and retrieves only the code it needs – 88-99% fewer tokens on every operation.

toktoken index:create            # index your project (once)
toktoken search:symbols "auth"   # find symbols by name
toktoken inspect:symbol      # retrieve just the code that matters

Works with Claude Code, Cursor, Windsurf, Copilot, Gemini, Codex, and any MCP-compatible agent. Single binary, zero dependencies, nothing written inside your project.

Quick setup: tell your AI agent to read docs/LLM.md – it will install and configure TokToken (almost) autonomously. For the rest of you, humans, keep reading.

Features

  • 49 languages via universal-ctags + 16 custom parsers (see docs/LANGUAGES.md)
  • Import graph: cross-file dependency tracking with find:importers, find:references, find:callers, and inspect:dependencies
  • FTS5 search with relevance scoring, cascading query strategies, and token-budget-aware result slicing
  • Incremental indexing using content hashing – re-indexes only changed files, including single-file reindex
  • Dead code detection: find symbols with no callers or importers across the codebase
  • Blast radius analysis: trace all files and symbols affected by a change to a given file or symbol
  • Circular import detection: identify import cycles in the dependency graph
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "toktoken": { "command": "toktoken", "args": ["serve"] } } }