Commit 84b9ad9
committed
Make MCP indexing observable and tools available immediately
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_015SPsWy8a63EpYMFDJjVE1e1 parent 16b4658 commit 84b9ad9
6 files changed
Lines changed: 331 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
50 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
69 | 80 | | |
70 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
71 | 84 | | |
72 | 85 | | |
73 | 86 | | |
| |||
76 | 89 | | |
77 | 90 | | |
78 | 91 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
85 | 100 | | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
90 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
91 | 110 | | |
92 | 111 | | |
93 | 112 | | |
94 | 113 | | |
95 | | - | |
| 114 | + | |
| 115 | + | |
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
99 | | - | |
| 119 | + | |
100 | 120 | | |
101 | 121 | | |
102 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| 107 | + | |
101 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
105 | 119 | | |
| 120 | + | |
| 121 | + | |
106 | 122 | | |
107 | 123 | | |
108 | 124 | | |
| |||
121 | 137 | | |
122 | 138 | | |
123 | 139 | | |
| 140 | + | |
| 141 | + | |
124 | 142 | | |
125 | 143 | | |
126 | 144 | | |
| |||
139 | 157 | | |
140 | 158 | | |
141 | 159 | | |
142 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
143 | 164 | | |
144 | 165 | | |
145 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
146 | 174 | | |
147 | 175 | | |
148 | 176 | | |
| |||
157 | 185 | | |
158 | 186 | | |
159 | 187 | | |
| 188 | + | |
| 189 | + | |
160 | 190 | | |
161 | 191 | | |
162 | 192 | | |
| |||
168 | 198 | | |
169 | 199 | | |
170 | 200 | | |
| 201 | + | |
| 202 | + | |
171 | 203 | | |
172 | 204 | | |
173 | 205 | | |
| |||
220 | 252 | | |
221 | 253 | | |
222 | 254 | | |
223 | | - | |
| 255 | + | |
224 | 256 | | |
225 | 257 | | |
226 | 258 | | |
227 | 259 | | |
228 | 260 | | |
229 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
230 | 266 | | |
231 | 267 | | |
232 | 268 | | |
| |||
239 | 275 | | |
240 | 276 | | |
241 | 277 | | |
| 278 | + | |
242 | 279 | | |
243 | | - | |
| 280 | + | |
| 281 | + | |
244 | 282 | | |
245 | 283 | | |
246 | 284 | | |
247 | 285 | | |
248 | 286 | | |
249 | | - | |
| 287 | + | |
| 288 | + | |
250 | 289 | | |
251 | 290 | | |
252 | 291 | | |
| |||
0 commit comments