← Back to MCP servers

MongoDB

MongoDB MCP Server

Query, aggregate, and manage MongoDB collections and databases from your AI coding assistant.

Connection string

Last reviewed Mar 2, 2026

Install

claude mcp add mongodb --transport stdio -- npx -y mongodb-mcp-server
Scope: project

Environment variables required:

MONGODB_URI=mongodb://localhost:27017/mydb

Available tools

ToolDescription
findQuery documents in a collection with filters
aggregateRun aggregation pipeline queries
insertInsert documents into a collection
updateUpdate documents matching a filter
list_databasesList all databases on the server
list_collectionsList collections in a database

What it does

The MongoDB MCP Server connects your AI coding assistant to a MongoDB instance, providing full CRUD and aggregation capabilities. It can query documents, run aggregation pipelines, inspect database schemas, and manage collections -- giving the assistant deep understanding of your NoSQL data layer.

This server is particularly useful when building applications with MongoDB as the data store. The assistant can explore your document structures, write and test complex aggregation queries, and help you design efficient data models based on your actual data.

Use cases

  • Explore collection schemas and document structures to inform application development
  • Write and test MongoDB aggregation pipelines with real data
  • Query documents to debug data-related issues in your application
  • List databases and collections to understand your data organization
  • Generate Mongoose schemas or MongoDB driver code based on actual document structures
  • Insert test data for development and integration testing

Getting started

  1. Prepare your MongoDB connection string. For local development, this is typically mongodb://localhost:27017/mydb. For MongoDB Atlas, use the connection string from your cluster's connect dialog.
  2. Set the MONGODB_URI environment variable to your connection string.
  3. For MongoDB Atlas, ensure your IP address is in the cluster's access list and your database user has the appropriate read/write permissions.
  4. The server has full read and write access, so use a development database or a restricted user account to limit the scope of operations on production data.