MongoDB

Provides read-only access to MongoDB data, including schema inspection and aggregation capabilities for MCP clients.
  • javascript

0

GitHub Stars

javascript

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "mcp-mirror-mongodb-developer_mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@pash1986/mcp-server-mongodb"
      ],
      "env": {
        "MONGODB_URI": "mongodb+srv://<yourcluster>"
      }
    }
  }
}

This MCP server gives you read-only access to MongoDB data for models and LLMs. It lets you inspect collection schemas and run aggregation pipelines securely, providing structured results and schema insights without modifying your data.

How to use

You connect to a MongoDB MCP Server from your MCP client by running the server locally (or remotely) and configuring the client to reach it. The server exposes two primary tools for querying MongoDB: aggregation (aggregate) and query explanation (explain). Use aggregate to run pipelines against a collection to fetch transformed results, and use explain to obtain execution plans for those pipelines.

You can also access inferred schema information for each collection via a dedicated endpoint that returns a JSON schema derived from sampled documents. This helps you understand field names and data types without inspecting raw data manually.

Common usage patterns include inspecting a collection’s schema to design pipelines, running aggregation pipelines to summarize data, and using explain to optimize your pipelines for performance.

How to install

Prerequisites: ensure you have Node.js and npm (or a compatible runtime) installed on your system.

  1. Prepare the MongoDB connection URI for your database and ensure it is accessible from the machine running the MCP server.

  2. Start the MCP server using the provided command. The server is run via a package runner to fetch and execute the MCP package.

  3. Point your MCP client to the server and provide the connection URI as an environment variable when starting the server.

Configuration, security, examples, notes

Environment variables: you need to supply the MongoDB connection URI through an environment variable named MONGODB_URI. This is used by the server to connect to your MongoDB instance.

Usage notes: the server operates in read-only mode. Aggregation pipelines are executed against the connected database, and results are returned to the client. If a pipeline does not include a limit stage, the server enforces a default limit of 1000 documents. All operations have a default timeout of 30 seconds to avoid hanging queries.

Endpoints: the server can provide schema information for each collection at a path resembling mongodb://<host>/<collection>/schema, where you can fetch inferred JSON schema details including field names and data types.

Tools supported by the server include: aggregate for executing MongoDB aggregation pipelines and explain for obtaining execution plans.

Example usage patterns

Basic aggregation example: you can aggregate over a collection to compute aggregates like sums, averages, or counts grouped by a field. You can also limit and sort results as needed.

Query explanation example: you can request an execution plan for a given pipeline to understand which stages will be executed and where optimizations may be needed.

Safety features

Automatic limit of 1000 documents if no limit is specified in the pipeline.

Default timeout of 30 seconds for all operations.

Read-only operations only.

Safe schema inference from collection samples to minimize heavy scans.

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License.

Available tools

aggregate

Execute MongoDB aggregation pipelines against the connected database. Accepts a collection name, a pipeline array, and optional settings like allowDiskUse, maxTimeMS, and comment. Defaults to a limit of 1000 documents and a 30-second timeout.

explain

Get execution plans for aggregation pipelines. Accepts a collection name, a pipeline array, and a verbosity level (queryPlanner, executionStats, allPlansExecution).

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational