MongoDB

MongoDB

A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.

6.7K

4

20 Tools

Signed
Built by Docker
Requires Secrets
Add to Docker Desktop

Version 4.43 or later needs to be installed to add the server automatically

About

MongoDB MCP Server

A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.

What is an MCP Server?

Characteristics

AttributeDetails
Docker Imagemcp/mongodb
Authormongodb-js
Repositoryhttps://github.com/mongodb-js/mongodb-mcp-server
Dockerfilehttps://github.com/mongodb-js/mongodb-mcp-server/blob/main/Dockerfile
Docker Image built byDocker Inc.
Docker Scout Health ScoreDocker Scout Health Score
Verify SignatureCOSIGN_REPOSITORY=mcp/signatures cosign verify mcp/mongodb --key https://raw.githubusercontent.com/docker/keyring/refs/heads/main/public/mcp/latest.pub
LicenceApache License 2.0

Available Tools (20)

Tools provided by this ServerShort Description
aggregateaggregate
collection-indexescollection-indexes
collection-schemacollection-schema
collection-storage-sizecollection-storage-size
countcount
create-collectioncreate-collection
create-indexcreate-index
db-statsdb-stats
delete-manydelete-many
drop-collectiondrop-collection
drop-databasedrop-database
explainexplain
findfind
insert-manyinsert-many
list-collectionslist-collections
list-databaseslist-databases
mongodb-logsmongodb-logs
rename-collectionrename-collection
switch-connectionswitch-connection
update-manyupdate-many

Tools Details

Tool: aggregate

Run an aggregation against a MongoDB collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
pipelinearrayAn array of aggregation stages to execute

This tool is read-only. It does not modify its environment.


Tool: collection-indexes

Describe the indexes for a collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name

This tool is read-only. It does not modify its environment.


Tool: collection-schema

Describe the schema for a collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name

This tool is read-only. It does not modify its environment.


Tool: collection-storage-size

Gets the size of the collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name

This tool is read-only. It does not modify its environment.


Tool: count

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

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
queryobjectoptionalA filter/query parameter. Allows users to filter the documents to count. Matches the syntax of the filter argument of db.collection.count().

This tool is read-only. It does not modify its environment.


Tool: create-collection

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

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name

Tool: create-index

Create an index for a collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
keysobjectThe index definition
namestringoptionalThe name of the index

Tool: db-stats

Returns statistics that reflect the use state of a single database

ParametersTypeDescription
databasestringDatabase name

This tool is read-only. It does not modify its environment.


Tool: delete-many

Removes all documents that match the filter from a MongoDB collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
filterobjectoptionalThe query filter, specifying the deletion criteria. Matches the syntax of the filter argument of db.collection.deleteMany()

This tool may perform destructive updates.


Tool: drop-collection

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

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name

This tool may perform destructive updates.


Tool: drop-database

Removes the specified database, deleting the associated data files

ParametersTypeDescription
databasestringDatabase name

This tool may perform destructive updates.


Tool: explain

Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
methodarrayThe method and its arguments to run

This tool is read-only. It does not modify its environment.


Tool: find

Run a find query against a MongoDB collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
filterobjectoptionalThe query filter, matching the syntax of the query argument of db.collection.find()
limitnumberoptionalThe maximum number of documents to return
projectionobjectoptionalThe projection, matching the syntax of the projection argument of db.collection.find()
sortobjectoptionalA document, describing the sort order, matching the syntax of the sort argument of cursor.sort()

This tool is read-only. It does not modify its environment.


Tool: insert-many

Insert an array of documents into a MongoDB collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
documentsarrayThe array of documents to insert, matching the syntax of the document argument of db.collection.insertMany()

Tool: list-collections

List all collections for a given database

ParametersTypeDescription
databasestringDatabase name

This tool is read-only. It does not modify its environment.


Tool: list-databases

List all databases for a MongoDB connection

Tool: mongodb-logs

Returns the most recent logged mongod events

ParametersTypeDescription
limitintegeroptionalThe maximum number of log entries to return.
typestringoptionalThe type of logs to return. Global returns all recent log entries, while startupWarnings returns only warnings and errors from when the process started.

This tool is read-only. It does not modify its environment.


Tool: rename-collection

Renames a collection in a MongoDB database

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
newNamestringThe new name for the collection
dropTargetbooleanoptionalIf true, drops the target collection if it exists

Tool: switch-connection

Switch to a different MongoDB connection. If the user has configured a connection string or has previously called the connect tool, a connection is already established and there's no need to call this tool unless the user has explicitly requested to switch to a new instance.

ParametersTypeDescription
connectionStringstringoptionalMongoDB connection string to switch to (in the mongodb:// or mongodb+srv:// format)

This tool is read-only. It does not modify its environment.


Tool: update-many

Updates all documents that match the specified filter for a collection

ParametersTypeDescription
collectionstringCollection name
databasestringDatabase name
updateobjectAn update document describing the modifications to apply using update operator expressions
filterobjectoptionalThe selection criteria for the update, matching the syntax of the filter argument of db.collection.updateOne()
upsertbooleanoptionalControls whether to insert a new document if no documents match the filter

Use this MCP Server

{
  "mcpServers": {
    "mongodb": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "MDB_MCP_CONNECTION_STRING",
        "mcp/mongodb"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
      }
    }
  }
}

Why is it safer to run MCP Servers with Docker?

Manual installation

You can install the MCP server using:

Installation for

Related servers