Skip to content

Auto-reindex servers when their tools change - #93

Merged
evantahler merged 1 commit into
mainfrom
evantahler/reindex-changed-tools
Jun 4, 2026
Merged

Auto-reindex servers when their tools change#93
evantahler merged 1 commit into
mainfrom
evantahler/reindex-changed-tools

Conversation

@evantahler

Copy link
Copy Markdown
Collaborator

The search index previously only went stale when a server was removed or the embedding model changed — it never noticed when a still-configured server added, renamed, or changed a tool. This adds per-server drift detection (getDriftedServers in src/search/staleness.ts, a key-sorted signature over tool name + description + input_schema, needing no index schema change) and an incremental reindexServers that re-embeds only the drifted servers via the new maybeReindexDrift helper. mcpx (the default list) and mcpx index --status already fetch every server's live tools, so they now detect drift and refresh just the affected servers in the background, reporting which servers changed. Servers that fail to connect are never pruned, and no index is built where none exists. Adds unit tests for the drift cases, updates the README and both skill docs, and bumps the patch version to 0.21.10.

The search index only detected staleness from removed servers or a changed
embedding model — it never noticed when a still-configured server added,
renamed, or changed a tool. Add per-server drift detection (a key-sorted
signature over tool name + description + input_schema, requiring no index
schema change) and incrementally re-index only the drifted servers.

`mcpx` (the default list) and `mcpx index --status` already fetch every
server's live tools, so they now detect drift and refresh the affected
servers in the background, telling the user which servers changed. Servers
that fail to connect are never pruned, and no index is built where none
exists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@evantahler
evantahler merged commit 8a2c162 into main Jun 4, 2026
3 checks passed
@evantahler
evantahler deleted the evantahler/reindex-changed-tools branch June 4, 2026 06:08
evantahler added a commit that referenced this pull request Jun 4, 2026
* Fix flaky embedding tests by retrying transient HF model downloads

The `generateEmbedding` tests download the real embedding model
(Xenova/bge-small-en-v1.5) from Hugging Face at test time. CI has no model
cache, so every run re-downloads — and HF periodically rate-limits with a 429,
which failed the post-merge run for #93 even though that PR's own CI was green
(the flake just didn't hit that run). The merge gate was never broken; the
tests were non-deterministic.

- semantic.ts: retry the model load with exponential backoff on transient
  errors (429 / 5xx / "load file"), keeping the existing wasm→cpu device
  fallback. Benefits real users hitting the same 429 on first index, not just
  CI.
- ci.yml: cache ~/.cache/mcpx/transformers (keyed on model repo+revision) so
  the model downloads once and is reused, and pre-warm the cache before the
  test suite so a cold cache populates outside the tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Key the model cache by src/constants.ts hash with a restore-keys fallback

Hashing the cache dir itself is circular (the key is computed before restore,
when the dir is empty on a hosted runner). Instead key on src/constants.ts —
the source of truth for the model repo/revision — so a model change re-keys
the cache, and add a `transformers-` restore-keys prefix so we still restore a
warm cache (and avoid re-downloading from HF) even right after a model change.
The goal is rate-limit avoidance, not pinning exact contents.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant