Make MCP indexing observable and tools available immediately#56
Merged
Conversation
Addresses dev-team findings about CodeRAG-as-MCP-tool feeling broken at broad-root (e.g. /home) scale: "enabled" but not "usable", opaque status, and tools that aren't reachable in time inside Hermes/Claude Code/Codex. - Serve the MCP protocol immediately. run_mcp() moved warm-up (which downloads/loads the embedding model on first run) and the initial index into one background bootstrap thread, so mcp.run() — and thus tools/list — is reached at once. The toolset is registered synchronously in build_mcp(), so clients see all five tools right away instead of timing out behind the model download. This is the CodeRAG-side cause of the "tools registered but unusable" race. - Live, pollable index progress. New thread-safe IndexProgress (types.py) threaded from Indexer.index(live=...) up through CodeRAG.index() to the index_status tool, which now returns a `progress` object: state (idle/scanning/indexing/optimizing/ready/failed), files_discovered, files_to_index, files_indexed, chunks, current_path, elapsed, last_error. files_discovered ticks up during the long pre-embed scan, so a big index reads as "scanning" instead of a stuck 0. reindex drives the same object. - Earlier partial results. During a live (MCP background) index, buffered rows are committed every ~5s so dense search returns hits before the 8192-chunk flush boundary. Gated on live is not None, so the CLI, watcher and tests keep today's single-flush-at-end batching (defaults unchanged). - MCP best-practice polish. ToolAnnotations(readOnlyHint=True) on search_code/search_files/get_file/index_status; reindex marked non-read-only. - Concurrency safety. Serving before warm-up means a query can arrive mid bootstrap; guard CodeRAG's lazy provider/store/searcher/indexer construction with a reentrant build lock so two threads can't build a second conflicting LanceStore. Tests: live-progress + failure-path tests in test_indexer.py; live progress, annotations, and reindex-progress assertions in test_mcp.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015SPsWy8a63EpYMFDJjVE1e
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mypy flagged the [assignment] code in the type: ignore on the ImportError fallback as unused; keep [misc] for the alias redefinition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses dev-team findings about CodeRAG-as-MCP-tool feeling broken at
broad-root (e.g. /home) scale: "enabled" but not "usable", opaque status,
and tools that aren't reachable in time inside Hermes/Claude Code/Codex.
Serve the MCP protocol immediately. run_mcp() moved warm-up (which
downloads/loads the embedding model on first run) and the initial index
into one background bootstrap thread, so mcp.run() — and thus tools/list
— is reached at once. The toolset is registered synchronously in
build_mcp(), so clients see all five tools right away instead of timing
out behind the model download. This is the CodeRAG-side cause of the
"tools registered but unusable" race.
Live, pollable index progress. New thread-safe IndexProgress (types.py)
threaded from Indexer.index(live=...) up through CodeRAG.index() to the
index_status tool, which now returns a
progressobject: state(idle/scanning/indexing/optimizing/ready/failed), files_discovered,
files_to_index, files_indexed, chunks, current_path, elapsed, last_error.
files_discovered ticks up during the long pre-embed scan, so a big index
reads as "scanning" instead of a stuck 0. reindex drives the same object.
Earlier partial results. During a live (MCP background) index, buffered
rows are committed every ~5s so dense search returns hits before the
8192-chunk flush boundary. Gated on live is not None, so the CLI, watcher
and tests keep today's single-flush-at-end batching (defaults unchanged).
MCP best-practice polish. ToolAnnotations(readOnlyHint=True) on
search_code/search_files/get_file/index_status; reindex marked non-read-only.
Concurrency safety. Serving before warm-up means a query can arrive mid
bootstrap; guard CodeRAG's lazy provider/store/searcher/indexer
construction with a reentrant build lock so two threads can't build a
second conflicting LanceStore.
Tests: live-progress + failure-path tests in test_indexer.py; live
progress, annotations, and reindex-progress assertions in test_mcp.py.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_015SPsWy8a63EpYMFDJjVE1e