cocoindex-code 0.1.10__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cocoindex-code
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: MCP server for indexing and querying codebases using CocoIndex
5
5
  Project-URL: Homepage, https://github.com/cocoindex-io/cocoindex-code
6
6
  Project-URL: Repository, https://github.com/cocoindex-io/cocoindex-code
@@ -123,7 +123,17 @@ Or use opencode.json:
123
123
  }
124
124
  ```
125
125
 
126
- Optionally, you can run `cocoindex-code index` to create or update the index. Without running it, the MCP server will automatically build and keep the index up-to-date in the background.
126
+ ### Build the Index
127
+
128
+ For large codebases, we recommend running the indexer once before using the MCP so you can see the progress:
129
+
130
+ ```bash
131
+ cocoindex-code index
132
+ ```
133
+
134
+ This lets you monitor the indexing process and ensure everything is ready. After the initial build, the MCP server will automatically keep the index up-to-date in the background as files change.
135
+
136
+ For small projects you can skip this step — the MCP server will build the index automatically on first use.
127
137
 
128
138
  ## When Is the MCP Triggered?
129
139
 
@@ -298,7 +308,7 @@ claude mcp add cocoindex-code \
298
308
  -- cocoindex-code
299
309
  ```
300
310
 
301
- > **Note:** Switching models requires re-indexing your codebase (the vector dimensions differ).
311
+ **Note:** Switching models requires re-indexing your codebase (the vector dimensions differ).
302
312
 
303
313
  ## MCP Tools
304
314
 
@@ -88,7 +88,17 @@ Or use opencode.json:
88
88
  }
89
89
  ```
90
90
 
91
- Optionally, you can run `cocoindex-code index` to create or update the index. Without running it, the MCP server will automatically build and keep the index up-to-date in the background.
91
+ ### Build the Index
92
+
93
+ For large codebases, we recommend running the indexer once before using the MCP so you can see the progress:
94
+
95
+ ```bash
96
+ cocoindex-code index
97
+ ```
98
+
99
+ This lets you monitor the indexing process and ensure everything is ready. After the initial build, the MCP server will automatically keep the index up-to-date in the background as files change.
100
+
101
+ For small projects you can skip this step — the MCP server will build the index automatically on first use.
92
102
 
93
103
  ## When Is the MCP Triggered?
94
104
 
@@ -263,7 +273,7 @@ claude mcp add cocoindex-code \
263
273
  -- cocoindex-code
264
274
  ```
265
275
 
266
- > **Note:** Switching models requires re-indexing your codebase (the vector dimensions differ).
276
+ **Note:** Switching models requires re-indexing your codebase (the vector dimensions differ).
267
277
 
268
278
  ## MCP Tools
269
279
 
@@ -0,0 +1,11 @@
1
+ """CocoIndex Code - MCP server for indexing and querying codebases."""
2
+
3
+ import logging
4
+
5
+ logging.basicConfig(level=logging.WARNING)
6
+
7
+ from .config import Config # noqa: E402
8
+ from .server import main, mcp # noqa: E402
9
+
10
+ __version__ = "0.1.0"
11
+ __all__ = ["Config", "main", "mcp"]
@@ -30,6 +30,9 @@ mcp = FastMCP(
30
30
  # Lock to prevent concurrent index updates
31
31
  _index_lock = asyncio.Lock()
32
32
 
33
+ # Event set once the initial background index is ready
34
+ _initial_index_done = asyncio.Event()
35
+
33
36
 
34
37
  async def _refresh_index() -> None:
35
38
  """Refresh the index. Uses lock to prevent concurrent updates."""
@@ -123,6 +126,16 @@ async def search(
123
126
  ),
124
127
  ) -> SearchResultModel:
125
128
  """Query the codebase index."""
129
+ if not _initial_index_done.is_set():
130
+ return SearchResultModel(
131
+ success=False,
132
+ message=(
133
+ "The index is still being built — this may take a while"
134
+ " for a large codebase or after significant changes."
135
+ " Please try again shortly."
136
+ ),
137
+ )
138
+
126
139
  try:
127
140
  # Refresh index if requested
128
141
  if refresh_index:
@@ -167,8 +180,15 @@ async def search(
167
180
 
168
181
  async def _async_serve() -> None:
169
182
  """Async entry point for the MCP server."""
183
+
170
184
  # Refresh index in background so startup isn't blocked
171
- asyncio.create_task(_refresh_index())
185
+ async def _initial_index() -> None:
186
+ try:
187
+ await _refresh_index()
188
+ finally:
189
+ _initial_index_done.set()
190
+
191
+ asyncio.create_task(_initial_index())
172
192
  await mcp.run_stdio_async()
173
193
 
174
194
 
@@ -1,7 +0,0 @@
1
- """CocoIndex Code - MCP server for indexing and querying codebases."""
2
-
3
- from .config import Config
4
- from .server import main, mcp
5
-
6
- __version__ = "0.1.0"
7
- __all__ = ["Config", "main", "mcp"]
File without changes