A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.
10K+
5
21 Tools
Version 4.43 or later needs to be installed to add the server automatically
Use cases
About
A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.
Attribute | Details |
---|---|
Docker Image | mcp/mongodb |
Author | mongodb-js |
Repository | https://github.com/mongodb-js/mongodb-mcp-server |
Dockerfile | https://github.com/mongodb-js/mongodb-mcp-server/blob/main/Dockerfile |
Docker Image built by | Docker Inc. |
Docker Scout Health Score | |
Verify Signature | COSIGN_REPOSITORY=mcp/signatures cosign verify mcp/mongodb --key https://raw.githubusercontent.com/docker/keyring/refs/heads/main/public/mcp/latest.pub |
Licence | Apache License 2.0 |
Tools provided by this Server | Short Description |
---|---|
aggregate | aggregate |
collection-indexes | collection-indexes |
collection-schema | collection-schema |
collection-storage-size | collection-storage-size |
connect | connect |
count | count |
create-collection | create-collection |
create-index | create-index |
db-stats | db-stats |
delete-many | delete-many |
drop-collection | drop-collection |
drop-database | drop-database |
explain | explain |
export | export |
find | find |
insert-many | insert-many |
list-collections | list-collections |
list-databases | list-databases |
mongodb-logs | mongodb-logs |
rename-collection | rename-collection |
update-many | update-many |
aggregate
Run an aggregation against a MongoDB collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
pipeline | array | An array of aggregation stages to execute |
This tool is read-only. It does not modify its environment.
collection-indexes
Describe the indexes for a collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
This tool is read-only. It does not modify its environment.
collection-schema
Describe the schema for a collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
This tool is read-only. It does not modify its environment.
collection-storage-size
Gets the size of the collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
This tool is read-only. It does not modify its environment.
connect
Connect to a MongoDB instance
Parameters | Type | Description |
---|---|---|
connectionString | string | MongoDB connection string (in the mongodb:// or mongodb+srv:// format) |
This tool is read-only. It does not modify its environment.
count
Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
query | object optional | A 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.
create-collection
Creates a new collection in a database. If the database doesn't exist, it will be created automatically.
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
create-index
Create an index for a collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
keys | object | The index definition |
name | string optional | The name of the index |
db-stats
Returns statistics that reflect the use state of a single database
Parameters | Type | Description |
---|---|---|
database | string | Database name |
This tool is read-only. It does not modify its environment.
delete-many
Removes all documents that match the filter from a MongoDB collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
filter | object optional | The query filter, specifying the deletion criteria. Matches the syntax of the filter argument of db.collection.deleteMany() |
This tool may perform destructive updates.
drop-collection
Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
This tool may perform destructive updates.
drop-database
Removes the specified database, deleting the associated data files
Parameters | Type | Description |
---|---|---|
database | string | Database name |
This tool may perform destructive updates.
explain
Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
method | array | The method and its arguments to run |
This tool is read-only. It does not modify its environment.
export
Export a query or aggregation results in the specified EJSON format.
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
exportTarget | array | The export target along with its arguments. |
exportTitle | string | A short description to uniquely identify the export. |
jsonExportFormat | string optional | The format to be used when exporting collection data as EJSON with default being relaxed. |
relaxed: A string format that emphasizes readability and interoperability at the expense of type preservation. That is, conversion from relaxed format to BSON can lose type information. | ||
canonical: A string format that emphasizes type preservation at the expense of readability and interoperability. That is, conversion from canonical to BSON will generally preserve type information except in certain specific cases. |
This tool is read-only. It does not modify its environment.
find
Run a find query against a MongoDB collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
filter | object optional | The query filter, matching the syntax of the query argument of db.collection.find() |
limit | number optional | The maximum number of documents to return |
projection | object optional | The projection, matching the syntax of the projection argument of db.collection.find() |
sort | object optional | A 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 ascending, -1 for descending). |
This tool is read-only. It does not modify its environment.
insert-many
Insert an array of documents into a MongoDB collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
documents | array | The 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
Parameters | Type | Description |
---|---|---|
database | string | Database name |
This tool is read-only. It does not modify its environment.
list-databases
List all databases for a MongoDB connection
mongodb-logs
Returns the most recent logged mongod events
Parameters | Type | Description |
---|---|---|
limit | integer optional | The maximum number of log entries to return. |
type | string optional | The 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.
rename-collection
Renames a collection in a MongoDB database
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
newName | string | The new name for the collection |
dropTarget | boolean optional | If true, drops the target collection if it exists |
update-many
Updates all documents that match the specified filter for a collection
Parameters | Type | Description |
---|---|---|
collection | string | Collection name |
database | string | Database name |
update | object | An update document describing the modifications to apply using update operator expressions |
filter | object optional | The selection criteria for the update, matching the syntax of the filter argument of db.collection.updateOne() |
upsert | boolean optional | Controls whether to insert a new document if no documents match the filter |
{
"mcpServers": {
"mongodb": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MDB_MCP_CONNECTION_STRING",
"mcp/mongodb"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
}
}
}
}
Manual installation
You can install the MCP server using:
Installation for