Skip to main content

MongoDBVectorSearchTool

Description

Perform vector similarity queries on MongoDB Atlas collections. Supports index creation helpers and bulk insert of embedded texts. MongoDB Atlas supports native vector search. Learn more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/

Installation

Install with the MongoDB extra:
or

Parameters

Initialization

  • connection_string (str, required)
  • database_name (str, required)
  • collection_name (str, required)
  • vector_index_name (str, default vector_index)
  • text_key (str, default text)
  • embedding_key (str, default embedding)
  • dimensions (int, default 1536)

Run Parameters

  • query (str, required): Natural language query to embed and search.

Quick start

Code

Index creation helpers

Use create_vector_search_index(...) to provision an Atlas Vector Search index with the correct dimensions and similarity.

Common issues

  • Authentication failures: ensure your Atlas IP Access List allows your runner and the connection string includes credentials.
  • Index not found: create the vector index first; name must match vector_index_name.
  • Dimensions mismatch: align embedding model dimensions with dimensions.

More examples

Basic initialization

Code

Custom query configuration

Code

Preloading the database and creating the index

Code

Example

Code