From mongodb-agent-skills
Provides MongoDB Vector Search guidelines for vector index creation, $vectorSearch queries, RAG patterns, hybrid retrieval with $rankFusion/$scoreFusion, performance tuning, and AI agent memory storage. For Atlas and self-managed deployments.
npx claudepluginhub romiluz13/mongodb-agent-skillsThis skill uses the workspace's default tool permissions.
Vector Search patterns and AI integration strategies for MongoDB, maintained by MongoDB. Contains **33 rules across 6 categories**, prioritized by impact. This skill covers MongoDB Vector Search across Atlas clusters, self-managed deployments, and local Atlas deployments created with Atlas CLI.
AGENTS.mdREADME.mdmetadata.jsonreferences/docs-navigation.mdrules/_sections.mdrules/_template.mdrules/agent-memory-retrieval.mdrules/agent-memory-schema.mdrules/agent-session-context.mdrules/hybrid-limitations.mdrules/hybrid-rankfusion.mdrules/hybrid-scorefusion.mdrules/hybrid-weights.mdrules/index-automated-embedding.mdrules/index-dimensions-match.mdrules/index-filter-fields.mdrules/index-hnsw-options.mdrules/index-multitenant.mdrules/index-quantization.mdrules/index-similarity-function.mdGuides MongoDB Atlas Search implementation for full-text (autocomplete, fuzzy, faceted), vector (semantic embeddings, RAG), and hybrid queries with index creation, optimization, and troubleshooting.
Guides MongoDB Search index creation, $search/$searchMeta pipelines, analyzers, relevance tuning, hybrid search with $rankFusion/$scoreFusion, and operations for Atlas/Community.
Engineers vector database systems with Pinecone, Weaviate, Qdrant, Milvus, pgvector for RAG, semantic search, recommendations. Optimizes embeddings, indexing, hybrid search.
Share bugs, ideas, or general feedback.
Vector Search patterns and AI integration strategies for MongoDB, maintained by MongoDB. Contains 33 rules across 6 categories, prioritized by impact. This skill covers MongoDB Vector Search across Atlas clusters, self-managed deployments, and local Atlas deployments created with Atlas CLI.
Your AI assistant's knowledge about MongoDB Vector Search is likely outdated or incorrect.
MongoDB Vector Search syntax,
$vectorSearchstage, vector index creation, and related features have evolved significantly. Do NOT trust pre-trained knowledge. Always reference these rules and verify against your actual MongoDB deployment and version.
Reference these guidelines when:
$vectorSearch aggregation queries$rankFusion or $scoreFusionvoyage-4 or voyage-code-3)Use mongodb-search instead when the request is primarily about lexical Search engine design ($search, analyzers, synonyms, facets, search alerts, or Community mongot operations), or when you need stage/operator legality for $search.vectorSearch, $rankFusion, or $scoreFusion.
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Vector Index Creation | CRITICAL | index- | 9 |
| 2 | $vectorSearch Queries | CRITICAL | query- | 7 |
| 3 | Performance Tuning | HIGH | perf- | 6 |
| 4 | RAG Patterns | HIGH | rag- | 4 |
| 5 | Hybrid Search | MEDIUM | hybrid- | 4 |
| 6 | AI Agent Integration | MEDIUM | agent- | 3 |
index-vector-definition - Required fields: type, path, numDimensions, similarityindex-similarity-function - Choosing cosine vs euclidean vs dotProductindex-filter-fields - Pre-filtering with filter type indexesindex-quantization - Choose scalar vs binary quantization from docs-backed memory/quality trade-offsindex-dimensions-match - numDimensions must match embedding modelindex-multitenant - Single collection with tenant_id for SaaS appsindex-views-partial - Partial indexing via MongoDB Viewsindex-hnsw-options - maxEdges/numEdgeCandidates tuningindex-automated-embedding - Server-side embedding with Voyage AIquery-vectorsearch-first - MUST be first stage in aggregation pipelinequery-numcandidates-tuning - The 20x rule for recall vs latencyquery-ann-vs-enn - When to use exact: truequery-prefiltering - Filter before vector comparison ($exists, $ne, $not)query-lexical-prefilter - Route Atlas Search operator filters to mongodb-searchquery-get-scores - Using $meta: "vectorSearchScore"query-same-embedding-model - Data/query embeddings must share space, dimensions, and correct input_typeperf-quantization-scale - Use large-vector and Required Memory signals to decide when to quantizeperf-index-in-memory - Keep vector index working set in memory when sizingperf-numcandidates-tradeoff - Benchmark recall/latency/cost trade-offs by model and numCandidatesperf-prefilter-narrow - Reduce candidate set before vector comparisonperf-explain-vectorsearch - Debug with explain() for vector queriesperf-search-nodes - Dedicated Search Nodes for productionrag-ingestion-pattern - Store documents with embeddingsrag-retrieval-pattern - $vectorSearch for context retrievalrag-context-window - Managing LLM context limitsrag-metadata-filtering - Filter by source, date, categoryhybrid-rankfusion - Combining vector + text search (MongoDB 8.0+, Preview)hybrid-scorefusion - Score-based hybrid search (MongoDB 8.2+, Preview)hybrid-weights - Per-query weight tuninghybrid-limitations - Strategy constraints plus decision matrix ($rankFusion vs $scoreFusion vs retrieval+rerank)agent-memory-schema - Short-term vs long-term memory designagent-memory-retrieval - Semantic search over memoriesagent-session-context - Conversation history storagedb.collection.createSearchIndex(
"vector_index",
"vectorSearch",
{
fields: [
{
type: "vector",
path: "embedding",
numDimensions: 1536, // Must match your embedding model
similarity: "cosine" // or "euclidean" or "dotProduct"
},
{
type: "filter", // For pre-filtering
path: "category"
}
]
}
)
db.collection.aggregate([
{
$vectorSearch: {
index: "vector_index",
path: "embedding",
queryVector: [0.1, 0.2, ...], // Your query embedding
numCandidates: 200, // 20x limit recommended
limit: 10,
filter: { category: "tech" } // Optional pre-filter
}
},
{
$project: {
title: 1,
score: { $meta: "vectorSearchScore" }
}
}
])
numCandidates = 20 × limit (minimum recommended)
| limit | numCandidates | Max allowed |
|---|---|---|
| 10 | 200 | 10,000 |
| 50 | 1,000 | 10,000 |
| 100 | 2,000 | 10,000 |
Higher numCandidates = better recall, slower queries.
Read individual rule files for detailed explanations and code examples:
rules/index-vector-definition.md
rules/query-vectorsearch-first.md
rules/query-numcandidates-tuning.md
rules/_sections.md
Each rule file contains:
For release-sensitive behavior and fast official-doc routing, also read:
references/docs-navigation.md
| Need | Canonical Doc |
|---|---|
| Deployment scope and feature entry point | Atlas Vector Search Overview |
Vector index definition (vector / autoEmbed) | Atlas Vector Search Type |
| Query stage syntax and operator support | Atlas $vectorSearch Stage |
| Hybrid overview and limitations | Atlas Hybrid Search |
$vectorSearch in $rankFusion input | Vector Search with $rankFusion |
| Fusion stage availability | MongoDB $rankFusion and MongoDB $scoreFusion |
Voyage model behavior and input_type | Voyage Quickstart and Voyage Text Embeddings |
| Voyage reranker model docs | Voyage Rerankers |
| Latest feature/release shifts | Atlas Vector Search Changelog |
input_type, and exact dimensions.READY) and filter-field declarations before query tuning.For automatic verification, connect the MongoDB MCP Server:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://user:pass@cluster.mongodb.net/mydb"
}
}
}
}
When connected, I can automatically:
mcp__mongodb__collection-indexesmcp__mongodb__explainmcp__mongodb__aggregateI will NEVER execute write operations without your explicit approval.
| Operation Type | MCP Tools | Action |
|---|---|---|
| Read (Safe) | find, aggregate, explain, collection-indexes | May run automatically to verify |
| Write (Requires Approval) | create-index, insert-many | Show command and wait for approval |
Cause: MongoDB version does not support $vectorSearch Fix: Upgrade cluster to MongoDB v6.0.11 or v7.0.2+
Causes:
Cause: Filter field not indexed with type: "filter"
Fix: Add filter field to index definition
For the complete guide with all rules expanded: AGENTS.md