-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Environment: Windows 11, Postgres 17 with pgvector (local Docker), Ollama with embeddinggemma, v0.2.2
Problem: search_codebase always returns "Codebase is not indexed" even after add_codebase completes successfully and data is confirmed in Postgres
(1,658 chunks).
Root cause: syncIndexedCodebasesFromCloud() runs on every search_codebase and add_codebase call (lines 130 and 355 in handlers.js). It queries
each Postgres collection for metadata with codebasePath, but the path matching/query logic fails with local Postgres. When it can't match paths,
it overwrites ~/.context/mcp-codebase-snapshot.json with {"codebases": {}}, destroying the indexed state.
The getIndexedCodebases() method reads from this file, finds no codebases, and returns [] β causing the "not indexed" error.
Evidence:
- Postgres has the data: SELECT count(*) FROM collection_hybrid_code_chunks_553990de returns 1,658 rows
- Metadata exists: SELECT DISTINCT metadata->>'codebasePath' FROM collection_hybrid_code_chunks_553990de returns the correct path
- Snapshot file gets wiped to empty {} after every search/add call
Workaround: Patch handlers.js to add return; at the top of syncIndexedCodebasesFromCloud(), then manually write the snapshot file with the correct
codebase entries.
Suggested fix: Either skip the cloud sync when using local Postgres (detect via config), or fix the metadata query in the sync method to correctly
match paths from local collections.