mongodb-mcp-server

v3.4.0
io.github.mongodb-js/mongodb-mcp-server Checked 2 hours ago Published 6 days ago

Official MongoDB MCP server: let AI agents search and manage databases and the Atlas data platform

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

aggregate-db

Run an aggregation against a MongoDB database

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
pipeline *arrayAn array of aggregation stages to execute. The first stage must be a database-level aggregation stage (one of `$changeStream`, `$currentOp`, `$documents`, `$listLocalSessions`, `$queryStats`). https:/…
responseBytesLimitnumberThe maximum number of bytes to return in the response. This value is capped by the server's configured maximum and cannot be exceeded.

aggregate

Run an aggregation against a MongoDB collection

collection-indexes

Describe the indexes for a collection

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

collection-schema

Describe the schema for a collection

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
responseBytesLimitnumberThe maximum number of bytes to return in the response. This value is capped by the server's configured maximum and cannot be exceeded. Ignored when the schema comes from the validator.
sampleSizenumberNumber of documents to sample for schema inference. Ignored when the schema comes from the validator.
schemaSourcestringWhere to derive the schema from. 'auto' uses the collection's $jsonSchema validator when it rejects invalid writes (validationLevel 'strict' with validationAction 'error' or 'errorAndLog', or validati…

collection-storage-size

Gets the size of the collection

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

connect

Connect to a MongoDB instance and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time.

ParameterTypeDescription
connectionString *stringMongoDB connection string (in the mongodb:// or mongodb+srv:// format)
connectionNamestringOptional short label for the connection (stored slugified with a short suffix, e.g. "staging" becomes staging-<suffix>). Shown in connection listings; helpful for telling multiple connections apart.

count

Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
queryobjectA filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().

create-collection

Creates a new collection in a database. If the database doesn't exist, it will be created automatically.

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

create-index

Create an index for a collection

db-stats

Returns statistics that reflect the use state of a single database

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

delete-many

Removes all documents that match the filter from a MongoDB collection

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
filterobjectThe query filter, specifying the deletion criteria. Matches the syntax of the filter argument of db.collection.deleteMany()

disconnect

Close a MongoDB connection and revoke its connectionId.

ParameterTypeDescription
connectionId *stringThe connectionId to disconnect.

drop-collection

Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

drop-database

Removes the specified database, deleting the associated data files

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

drop-index

Drop an index for the provided database and collection.

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
indexName *stringThe name of the index to be dropped.
type *stringThe type of index to be deleted. Use 'classic' for standard indexes and 'search' for atlas search and vector search indexes.

explain

Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method. Pipelines with $out or $merge stages are not accepted, because explain never writes.

export

Export a query or aggregation results in the specified EJSON format.

find

Run a find query against a MongoDB collection

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
filterobjectThe query filter, matching the syntax of the query argument of db.collection.find()
limitnumberThe maximum number of documents to return
projectionobjectThe projection, matching the syntax of the projection argument of db.collection.find()
responseBytesLimitnumberThe maximum number of bytes to return in the response. This value is capped by the server's configured maximum and cannot be exceeded.
sortobjectA document, describing the sort order, matching the syntax of the sort argument of cursor.sort(). The keys of the object are the fields to sort on, while the values are the sort directions (1 for asce…

insert-many

Insert an array of documents into a MongoDB collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider inserting them in batches.

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
documents *arrayThe array of documents to insert, matching the syntax of the document argument of db.collection.insertMany().

list-collections

List all collections for a given database

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name

list-connections

List the active MongoDB connections and their connectionIds. Use this to find a connectionId established earlier.

list-databases

List all databases for a MongoDB connection

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.

mongodb-logs

Returns the most recent logged mongod events

ParameterTypeDescription
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
limitintegerThe maximum number of log entries to return.
typestringThe type of logs to return. Global returns all recent log entries, while startupWarnings returns only warnings and errors from when the process started.

rename-collection

Renames a collection in a MongoDB database

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
newName *stringThe new name for the collection
dropTargetbooleanIf true, drops the target collection if it exists

update-many

Updates all documents that match the specified filter for a collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider updating them in batches.

ParameterTypeDescription
collection *stringCollection name
connectionId *stringThe connection to run the operation against. Use the id returned by one of the connect tools.
database *stringDatabase name
update *objectAn update document describing the modifications to apply using update operator expressions
filterobjectThe selection criteria for the update, matching the syntax of the filter argument of db.collection.updateOne()
upsertbooleanControls whether to insert a new document if no documents match the filter

search-knowledge

Search for information in the MongoDB Assistant knowledge base. This includes official documentation, curated expert guidance, and other resources provided by MongoDB. Supports filtering by data source and version.

ParameterTypeDescription
query *stringA natural language query to search for in the MongoDB Assistant knowledge base. This should be a single question or a topic that is relevant to the user's MongoDB use case.
dataSourcesarrayA list of one or more data sources to limit the search to. You can specify a specific version of a data source by providing the version label. If not provided, the latest version of all data sources w…
limitnumberThe maximum number of results to return

list-knowledge-sources

List available data sources in the MongoDB Assistant knowledge base. Use this to explore available data sources or to find search filter parameters to use in search-knowledge.