Vector Stores Integrations
Relevant source files
The following files were used as context for generating this wiki page:
Vector Stores Integrations within the Memory Context Browser (MCB) provide the persistence layer for semantic code search and agent memory. The project utilizes a multi-provider architecture that supports five distinct vector stores: Milvus, EdgeVec, Qdrant, Pinecone, and an Encrypted store. These integrations allow the system to store high-dimensional embeddings generated from codebase analysis and retrieve them through natural language queries.
The architecture follows Clean Architecture principles, where vector store implementations reside in the mcb-providers crate and implement port traits defined in the mcb-domain layer. This decoupling ensures that the core logic of the MCP server remains independent of specific database technologies.
Sources: README.md:12-14, AGENTS.md:273-285, crates/mcb-providers/Cargo.toml:7-10
Architecture and Data Flow
The vector store system is designed around a unified data model, ensuring consistency across different provider implementations. Data flows from the source code, through embedding providers, and into the configured vector store.
Generic Provider Data Flow
The following diagram illustrates how search results are processed and converted into domain-specific entities like SearchResult and FileInfo.
A brief explanation: This flow shows the transformation of raw JSON metadata retrieved from vector databases into structured domain objects used for semantic search responses.
Sources: crates/mcb-providers/src/utils/vector_store.rs:46-97
Unified Vector Schema
All providers adhere to a standardized set of fields to maintain interoperability.
| Field Name | Constant | Description |
|---|---|---|
id | VECTOR_FIELD_ID | Unique document identifier |
file_path | VECTOR_FIELD_FILE_PATH | Source file path |
start_line | VECTOR_FIELD_START_LINE | Beginning line of the code chunk |
content | VECTOR_FIELD_CONTENT | Raw text/code content |
vector | VECTOR_FIELD_VECTOR | The embedding vector |
language | VECTOR_FIELD_LANGUAGE | Programming language of the chunk |
metadata | VECTOR_FIELD_METADATA | JSON blob for additional data |
Sources: crates/mcb-utils/src/constants/vector_store.rs:136-160
Supported Providers
Milvus
Milvus is a primary cloud-native vector database supported by MCB. The integration uses a specific collection naming convention prefixed with mcb_ to ensure compatibility with regex patterns.
- Distance Metric: L2 (Euclidean distance).
- Indexing: Utilizes
IvfFlatwith a defaultnlistof 128. - Performance: Implements pagination with a batch size of 100 to stay under gRPC 4MB limits.
Sources: crates/mcb-utils/src/constants/vector_store.rs:41-94
EdgeVec
EdgeVec is a high-performance vector database utilized for local or edge deployments. It relies on HNSW (Hierarchical Navigable Small World) graphs for indexing.
- HNSW Parameters:
M=16,M0=32,ef_construction=200,ef_search=64. - Default Dimensions: 1536 (optimized for OpenAI embeddings).
- Quantization: Scalar quantization.
Sources: crates/mcb-utils/src/constants/vector_store.rs:11-30
Qdrant & Pinecone
- Qdrant: Uses
Cosinesimilarity as its default distance metric and operates on port 6333 by default. - Pinecone: Optimized for cloud-scale upserts with a default batch size of 100.
Sources: crates/mcb-utils/src/constants/vector_store.rs:104-118
Implementation Utilities
The mcb-providers crate contains shared utilities in src/utils/vector_store.rs to reduce duplication across provider implementations.
Result Mapping
The function search_result_from_json_metadata acts as a central mapper. It handles field extraction and provides fallbacks, such as using line_number if start_line is missing from the metadata.
Sources: crates/mcb-providers/src/utils/vector_store.rs:46-77
File Aggregation
build_file_info_from_results groups individual vector search hits by their file_path. This allows the system to report which files contain the most relevant context for a given query.
Sources: crates/mcb-providers/src/utils/vector_store.rs:84-97
A brief explanation: This class diagram represents the relationship between individual vector hits (SearchResult) and their summarized file-level metadata (FileInfo).
Sources: crates/mcb-providers/src/utils/vector_store.rs:46-97
Summary
The Vector Store Integrations in MCB provide a robust, multi-provider backend for semantic analysis. By utilizing standardized constants and shared utility functions, the system maintains high performance and consistency across varied storage engines like Milvus, EdgeVec, and Qdrant, supporting the overall goal of persistent, searchable agent memory.