Repository navigation
fix(core): keep index metadata when MCP status counts passages - #430
Merged
ASuresh0524 merged 1 commit intoOct 9, 2026
Merged
ASuresh0524 merged 1 commit into
ASuresh0524 merged 1 commit into
Conversation
handle_status() read the index metadata into `meta`, then reused that name for each passage's own metadata dict while counting chunks. After the loop the four fields reported by `leann_status` were read from the last passage's metadata, so every index with at least one passage reported Backend/Embedding/Dimensions as "unknown".
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.
What
handle_status()inpackages/leann-core/src/leann/mcp.pyloaded the index metadata intometaand then reused that same name for each passage's metadata dict while counting chunks. The four fields reported after the loop were therefore read from the last passage's metadata instead of the index's, soleann_statusansweredBackend: unknown,Embedding: unknown (unknown),Dimensions: unknownfor every index that has at least one passage.This renames the loop-local dict to
passage_metaand adds a regression test.Why
Fixes #429.
api.pywritesbackend_name,embedding_model,embedding_modeanddimensionsinto<index>.meta.jsonon every build, andleann_statusis the tool an MCP client uses to inspect an index — so the tool's description of a healthy index was wrong on all four fields. The counters from the same loop (Chunks,Files indexed,Size) stayed correct, which is why the response still looked plausible.How I checked
The new test drives
handle_status()through the same_base_dirseam astests/test_mcp_base_dir.py, and writes a meta.json plus a passages.jsonl — no embeddings, index build or network needed.Against the unfixed source (RED):
The passing case is
test_passage_counting_still_reports_chunks_and_files, i.e. the counters were never the problem.After the rename (GREEN), together with the neighbouring MCP tests:
Repo gates on the two changed files:
ruff checkandruff format --check: cleanty check packages/leann-core/src/leann/mcp.py tests/test_mcp_status_metadata.py: cleanNot run locally: the full
pytest tests/suite. This environment has the publishedleannwheel and neitherfaissnorhnswlibimportable, so the build/search tests cannot run here; CI covers them, and the change touches only a stdlib-only reporting function.I also reproduced the issue end-to-end against the published
leann0.3.8 wheel (see #429), which is what produced theunknownoutput quoted there.Note
This PR was prepared by an autonomous coding agent (AI-assisted); the diff is minimal and was verified as above, but no human on the author's side has read it before filing.