Repository navigation
Conversation
- Support metadata as JSON string, dict, or None - Add automatic deserialization of JSON strings with proper error handling - Handle edge cases (null, none, empty strings, whitespace) - Add comprehensive test suite with 13 test cases covering all scenarios - Maintain backward compatibility with existing dict/None metadata - Fix MCP interface issue where Claude serializes parameters to strings Resolves metadata validation error: 'Input validation error: ... is not valid under any of the given schemas' Technical changes: - Updated Union type annotation to include str in metadata parameter - Added JSON deserialization logic in store() function - Added validation for non-dict types after deserialization - Added comprehensive test coverage for all edge cases - All existing tests (37 total) continue to pass
- Add fallback to 'text' field when 'document' is not present - Ensures compatibility with different payload structures - Prevents KeyError when retrieving search results
|
This PR fixes a critical schema-implementation mismatch that currently breaks the The Problem: The MCP server's metadata parameter schema doesn't match its implementation. The schema only accepts object | null, but the implementation actually supports dict | str | None (JSON strings). This causes validation errors when Claude sends metadata as JSON strings: Input validation error: '{"code": "..."}' is not valid under any of the given schemas |
|
Thanks @MyWWWChat for reporting this and for the first fix! We took a slightly different approach in #219: the tool schema still asks for an object, and a JSON string of an object is converted before validation. It's merged and will be in the next release. |
* fix: accept metadata sent as a JSON string of an object Closes qdrant#85 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: parse metadata strings with pydantic's JSON parser It stops at 200 levels of nesting and rejects NaN and Infinity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The MCP server's metadata parameter schema doesn't match its implementation, causing validation errors when Claude (and other MCP clients) send metadata as JSON strings.
Current Issue:
object | nullfor metadatadict | str | None(can parse JSON strings)Input validation error: '{"code": "..."}' is not valid under any of the given schemasSolution
This PR fixes the schema-implementation mismatch by:
Metadata | NonetoUnion[Metadata, str, None]Technical Changes
src/mcp_server_qdrant/mcp_server.py
strtype"null","none", empty strings, whitespacesrc/mcp_server_qdrant/qdrant.py
'text'field when'document'is missing in search resultstests/test_metadata_deserialization.py
Testing
All tests pass:
Impact
This fix resolves the metadata validation error that prevents Claude and other MCP clients from using the metadata parameter as documented. The change is backward compatible - existing code using dict or None continues to work.
Related Issues
Fixes the error:
Input validation error: '{"code": "def test(): pass"}' is not valid under any of the given schemasThis enables proper usage as described in TOOL_STORE_DESCRIPTION: