Description
The parse_filter method in crates/dear-diary-mcp/src/server.rs currently cannot parse arbitrary JSON filters into Qdrant Filter objects because Qdrant's protobuf Filter type does not implement serde's Deserialize trait.
Current Behaviour
When allow_arbitrary_filter is set to true in the configuration, the server returns an error:
InvalidFilter("Arbitrary JSON filter parsing is not yet implemented")
See: crates/dear-diary-mcp/src/server.rs lines 63-81
Desired Behaviour
The server should be able to:
- Accept JSON filter structures via the
filter parameter in qdrant_find requests
- Parse these JSON structures into Qdrant
Filter objects
- Apply these filters when querying the vector database
Potential Approaches
-
Manual JSON→Filter construction: Write custom deserialisation logic to manually construct Filter objects from JSON structures by traversing the JSON and building the protobuf types directly.
-
Wrapper types with serde: Create wrapper types that implement serde traits and provide conversion methods to/from Qdrant's protobuf types.
-
Upstream serde support: Investigate whether Qdrant's Rust client could add serde support for protobuf types, or contribute this feature upstream.
-
Alternative filter API: Design a simplified, serde-compatible filter DSL specific to Dear Diary's use cases that can be translated to Qdrant filters.
-
serde_protobuf crate: Explore using the serde_protobuf crate for dynamic schema deserialisation, though this may require additional runtime overhead.
Technical Background
Protobuf-generated Rust types (using prost) typically do not implement serde traits by default. The Qdrant Rust client uses prost-generated types for its protobuf definitions, which means Filter lacks Deserialize implementation.
Possible technical solutions:
- Custom conversion logic from JSON → protobuf structures
- Intermediate representation that is serde-compatible
- Wrapper types with manual trait implementations
References
Related Code
fn parse_filter(&self, filter: Option<Value>) -> Result<Option<Filter>, McpServerError> {
let Some(_filter_value) = filter else {
return Ok(None);
};
if !self.settings.qdrant.allow_arbitrary_filter {
return Err(McpServerError::InvalidFilter(
"Arbitrary filters are not enabled".to_owned(),
));
}
// TODO: Implement proper filter parsing from JSON
Err(McpServerError::InvalidFilter(
"Arbitrary JSON filter parsing is not yet implemented".to_owned(),
))
}
Impact
- Users cannot currently use the
allow_arbitrary_filter configuration option
- Limited to filterable_fields configuration for query filtering
- Reduces flexibility for advanced filtering use cases
Description
The
parse_filtermethod incrates/dear-diary-mcp/src/server.rscurrently cannot parse arbitrary JSON filters into QdrantFilterobjects because Qdrant's protobufFiltertype does not implement serde'sDeserializetrait.Current Behaviour
When
allow_arbitrary_filteris set totruein the configuration, the server returns an error:See:
crates/dear-diary-mcp/src/server.rslines 63-81Desired Behaviour
The server should be able to:
filterparameter inqdrant_findrequestsFilterobjectsPotential Approaches
Manual JSON→Filter construction: Write custom deserialisation logic to manually construct
Filterobjects from JSON structures by traversing the JSON and building the protobuf types directly.Wrapper types with serde: Create wrapper types that implement serde traits and provide conversion methods to/from Qdrant's protobuf types.
Upstream serde support: Investigate whether Qdrant's Rust client could add serde support for protobuf types, or contribute this feature upstream.
Alternative filter API: Design a simplified, serde-compatible filter DSL specific to Dear Diary's use cases that can be translated to Qdrant filters.
serde_protobuf crate: Explore using the
serde_protobufcrate for dynamic schema deserialisation, though this may require additional runtime overhead.Technical Background
Protobuf-generated Rust types (using prost) typically do not implement serde traits by default. The Qdrant Rust client uses prost-generated types for its protobuf definitions, which means
FilterlacksDeserializeimplementation.Possible technical solutions:
References
Related Code
Impact
allow_arbitrary_filterconfiguration option