home / mcp / mongodb mcp server

MongoDB MCP Server

A mongo db server for the model context protocol (MCP)

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "rock913-mongo-mcp": {
      "command": "npx",
      "args": [
        "mongo-mcp",
        "mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
      ]
    }
  }
}

You can connect Claude-like MCP clients to a MongoDB database and perform queries, inspect schemas, and manage data using natural language. This MCP server enables you to interact with MongoDB collections directly, making data exploration and manipulation fast and intuitive from your preferred client.

How to use

Start by ensuring you have an MCP client (for example Claude Desktop) ready to connect to an MCP server. You will use the two available connection methods to run the MongoDB MCP Server locally or remotely. Once the server is running, you can ask your MCP client questions like: which collections exist, what is the schema of a collection, or find documents matching criteria. You can also create indexes and perform document operations such as insert, update, and delete.

How to install

Prerequisites you need before starting:
- Node.js 18 or newer
- npm or npx
- An MCP client (for example Claude Desktop) to connect to the server
- Docker and Docker Compose if you want to run a local sandbox (optional for testing)

Configure your MCP client to connect to MongoDB MCP Server using one or more of the following runtime configurations. You can run the server via a CLI command using npx or start a local development instance with Node.

{
  "mcpServers": {
    "mongodb_cli": {
      "command": "npx",
      "args": [
        "mongo-mcp",
        "mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
      ]
    },
    "mongodb_local": {
      "command": "node",
      "args": [
        "dist/index.js",
        "mongodb://root:example@localhost:27017/test?authSource=admin"
      ]
    }
  }
}

Additional setup and notes

Prerequisites also mention that you may seed a test sandbox if you need sample data to practice with. This helps you verify prompts and demonstrate capabilities like querying collections, inspecting schemas, and performing document updates in a safe environment.

Available tools

find

Query documents with filtering and projection to retrieve data that matches your criteria.

listCollections

List the available collections in the connected MongoDB database.

insertOne

Insert a single document into a collection to add new data.

updateOne

Update a single document in a collection based on a filter.

deleteOne

Delete a single document from a collection based on a filter.

createIndex

Create an index on a field or fields to improve query performance.

dropIndex

Remove an existing index from a collection.

indexes

List all indexes on a given collection.