Expand description
Compact tool catalog index for warm --search / --detail names.
Full MCP tool lists embed every inputSchema (multi‑MB). We store a small
parallel index:
- names (sorted) — exact/prefix via binary search
- tool_overrides — sparse MCP names when they are not kebab→snake
- postings — kebab-segment → tool ids (in memory only; rebuilt on load)
- descs — optional truncated text (omitted from v4 disk by default)
Session daemons keep this struct in RAM and search in-process. Disk is a thin non-session accelerator (names + overrides only).
The inverted postings map is the KV shape we need at ~3k tools. An embedded
KV engine (redb/sled) is not worth the deps unless catalogs grow far larger
or we need a shared index without a session daemon.
A BST does not help arbitrary substring search. Sorted names + postings are the right shape for CLI discovery.
Structs§
- Compact
Index - Compact index (v4 disk omits
descs/postings; v2/v3 still load). - Tool
Index Entry
Constants§
- DESC_
TRUNCATE - Max description chars retained when building with
with_descs: true. - INDEX_
VERSION - On-disk format: names + sparse overrides; postings rebuilt in memory.
Functions§
- build_
compact_ index - build_
index - find_
exact - Exact name lookup via binary search on sorted names.
- index_
cache_ key - index_
to_ commands - load_
compact_ index - load_
index - rebuild_
postings - Rebuild inverted postings from
names(used after v4 disk load). - save_
index - Persist names + overrides only (no descs / postings) for a slim disk sidecar.
- save_
tools_ and_ index - search_
compact - Search using postings when
patternis a single kebab token; else scan names. - search_
index - tools_
to_ light_ commands - try_
commands_ from_ index - Warm-path commands from disk index.