Skip to content

fix: clear error for incompatible collections, skip points without document - #212

Merged
chadha-sridi merged 2 commits into
masterfrom
fix/foreign-collection-errors
Nov 24, 2026
Merged

chadha-sridi merged 2 commits into
masterfrom
fix/foreign-collection-errors

Conversation

@chadha-sridi

Copy link
Copy Markdown
Contributor

fix: clear error for incompatible collections, skip points without document

Addresses section 3 of #188. Related to #10.

Supersedes #210. Credit to @FirdowsRahaman, who opened the first fix for the vector check.

Problem

The server assumes every collection was created by itself: a dense vector named after the embedding model (for example fast-all-minilm-l6-v2, size 384), and points whose payload has a document field. When a tool targets any other collection, the model gets an error that doesn't explain the cause:

Collection qdrant-find / qdrant-store on master
Unnamed vector 400 Bad Request: Not existing vector name error: fast-all-minilm-l6-v2
Vector with another name Same 400
Right name, wrong size 400 Bad Request: Vector dimension error: expected dim: 768, got 384
Some points without document qdrant-find crashes with KeyError, and the model only sees 'document'

The last case also discards the valid results, so a single foreign point breaks every search that returns it.

Changes

  • Vector check on every call. find and store already checked whether the collection exists on every call. They now fetch the collection info instead (get_collection, still one request) and compare its vectors with the embedding model's vector name and size. On a mismatch, they raise IncompatibleCollectionError with a message that names both sides and the setting to change:

    Collection 'docs' does not match the embedding model this server uses. The server needs a vector named 'fast-all-minilm-l6-v2' with size 384, but the collection has a single unnamed vector (size 768). The vector name and size come from EMBEDDING_MODEL: use the model the collection was created with, or use a different collection.

    There is no cache, so a collection that is recreated or changed is always checked against its current config.

  • Points without document are skipped. qdrant-find returns the valid points and adds a note so the model knows the results are incomplete:

    Note: 1 matching point was left out because its payload has no 'document' field. This tool only returns points that store their text in that field.

    The skipped points are also logged as a warning.

  • QdrantConnector.search() returns SearchResults, a list[Entry] subclass with a skipped count, so code that uses the connector directly keeps working. If a subclass overrides search() and returns a plain list, qdrant-find treats the count as 0.

Out of scope

Using existing collections with a different vector name or payload format (#10, #78, #98, #119) is a feature request. We are not adding it, since this server is being sunset. This PR only makes the failure clear.

Testing

  • Five new end-to-end tests in tests/test_mcp_server.py through fastmcp.Client:
    • The clear error for an unnamed vector, another vector name, and a wrong size, on both tools.
    • A mixed collection returns the valid point and the note.
    • A collection with only foreign points returns only the note.
  • All five fail on master and pass on this branch. Full suite: 54 passed.
  • Checked manually against Qdrant 1.20.0 in Docker: every case in the table above now returns the clear error or the note, and normal collections work as before.
  • pre-commit (ruff, ruff-format, isort, and mypy) passes.

🤖 Generated with Claude Code

@AstraBert AstraBert left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nitpicks, but overall looks good :)

Comment thread src/mcp_server_qdrant/mcp_server.py Resolved
Comment thread src/mcp_server_qdrant/mcp_server.py Resolved
Comment thread src/mcp_server_qdrant/mcp_server.py Resolved
@chadha-sridi

Copy link
Copy Markdown
Contributor Author

Thanks @AstraBert for the review, I applied all four requested changes:

  • DRY note: now a single message with "point(s)".
  • getattr: agreed, it was a band-aid that hid a breaking change. If someone's override returned a plain list, they'd silently lose the note, which is the exact problem this PR fixes. find now reads entries.skipped directly, so a wrong override fails loudly, and mypy checks the rest. SearchResults is still a list, so code that only calls search() is unaffected.
  • Being explicit about the change: I've added it to the breaking changes in the release notes for the next release: anyone who overrides search() must return SearchResults.
  • Truthiness: entries.skipped > 0, and entries.skipped == 0 in the check above it.

@chadha-sridi
chadha-sridi merged commit 4b5fcc8 into master Nov 24, 2026
5 checks passed
@chadha-sridi
chadha-sridi deleted the fix/foreign-collection-errors branch November 24, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants