$npx -y skills add mongodb/agent-skills --skill mongodb-search-and-aiGuides MongoDB users through implementing and optimizing Atlas Search (full-text), Vector Search (semantic), and Hybrid Search solutions. Use this skill when users need to build search functionality for text-based queries (autocomplete, fuzzy matching, faceted search), semantic s
| 1 | # MongoDB Search and AI Recommendations Skill |
| 2 | |
| 3 | You are helping MongoDB users implement, optimize, and troubleshoot Atlas Search (lexical), Vector Search (semantic), and Hybrid Search (combined) solutions. Your goal is to understand their use case, recommend the appropriate search approach, and help them build effective indexes and queries. |
| 4 | |
| 5 | ## Core Principles |
| 6 | |
| 7 | 1. **Understand before building** - Validate the use case to ensure you recommend the right solution |
| 8 | 2. **Always inspect first** - Check existing indexes and schema before making recommendations |
| 9 | 3. **Explain before executing** - Describe what indexes will be created and require explicit approval |
| 10 | 4. **Optimize for the use case** - Different use cases require different index configurations and query patterns |
| 11 | 5. **Handle read-only scenarios** - If you do not have access to `create`, `update`, or `delete` operation tools, you are in read-only mode. Provide the complete index configuration JSON so the user can create it themselves, including via the Atlas UI. |
| 12 | |
| 13 | ## Workflow |
| 14 | |
| 15 | ### 1. Discovery Phase |
| 16 | |
| 17 | **Check the environment:** |
| 18 | - Use `list-databases` and `list-collections` to understand available data |
| 19 | - If the user mentions a collection, use `collection-schema` to inspect field structure |
| 20 | - Use `collection-indexes` to see existing indexes |
| 21 | - Use `atlas-inspect-cluster` to determine the cluster's MongoDB version |
| 22 | |
| 23 | **Understand the use case:** |
| 24 | If the user's request is vague: |
| 25 | - Ask clarifying questions about their needs |
| 26 | - Infer likely collection and fields from schema |
| 27 | - Confirm understanding before proceeding |
| 28 | |
| 29 | Common questions to ask: |
| 30 | - What are users searching for? (products, movies, documents, etc.) |
| 31 | - What fields contain the searchable content? |
| 32 | - Do they need exact matching, fuzzy matching, or semantic similarity? |
| 33 | - Do they need filters (price ranges, categories, dates)? |
| 34 | - Do they need autocomplete/typeahead functionality? |
| 35 | |
| 36 | ### 2. Determine Search Type |
| 37 | |
| 38 | **Atlas Search (Lexical/Full-Text):** |
| 39 | Use when users need: |
| 40 | - Keyword matching with relevance scoring |
| 41 | - Fuzzy matching for typo tolerance |
| 42 | - Autocomplete/typeahead |
| 43 | - Faceted search with filters |
| 44 | - Language-specific text analysis |
| 45 | - Token-based search |
| 46 | - Lexical search with views |
| 47 | |
| 48 | **Vector Search (Semantic):** |
| 49 | Use when users need: |
| 50 | - Semantic similarity ("find movies about coming of age stories") |
| 51 | - Natural language understanding |
| 52 | - RAG (Retrieval Augmented Generation) applications |
| 53 | - Finding conceptually similar items |
| 54 | - Cross-modal search |
| 55 | - Vector search with views |
| 56 | |
| 57 | **Hybrid Search:** |
| 58 | Use when users need: |
| 59 | - Combining multiple search approaches (e.g., vector + lexical, multiple text searches) |
| 60 | - Queries like "find action movies similar to 'epic space battles'" (combining keyword filtering with semantic similarity) |
| 61 | - Results that factor in multiple relevance criteria |
| 62 | - Uses `$rankFusion` (rank-based) or `$scoreFusion` (score-based) to merge pipelines |
| 63 | |
| 64 | ### 3. Version Check (Hybrid Search only) |
| 65 | |
| 66 | If the search type is **Hybrid using `$rankFusion` or `$scoreFusion`**, verify the cluster version before proceeding: |
| 67 | - `$rankFusion` requires MongoDB 8.0+ |
| 68 | - `$scoreFusion` requires MongoDB 8.2+ |
| 69 | |
| 70 | If the version requirement is not met, do not proceed — inform the user the feature is unavailable and suggest upgrading. Do not consult `references/hybrid-search.md`. |
| 71 | |
| 72 | If the search type is Lexical, Vector, or the lexical prefilter pattern (`vectorSearch` operator inside `$search`), proceed to the next step. |
| 73 | |
| 74 | ### 4. Consult Reference Files |
| 75 | |
| 76 | Always consult the appropriate reference file(s) before recommending indexes or queries: |
| 77 | - **Lexical**: consult both `references/lexical-search-indexing.md` (index) and `references/lexical-search-querying.md` (query) |
| 78 | - **Vector**: consult `references/vector-search.md` |
| 79 | - **Hybrid**: consult `references/hybrid-search.md` (and the lexical/vector files for the individual pipeline stages within it) |
| 80 | |
| 81 | ### 5. Execution and Validation |
| 82 | |
| 83 | **Creating indexes:** |
| 84 | 1. Explain the index configuration in plain language |
| 85 | 2. Show the JSON structure |
| 86 | 3. Ask what the user wants to name the index |
| 87 | 4. Get explicit approval: "Should I create this index?" |
| 88 | 5. Use MCP's `create-index` tool after approval |
| 89 | 6. In read-only mode, provide the complete |