Mongo

Databases

A Model Context Protocol Server for MongoDB.

Your AI app calls the Mongo MCP server, which does the databases work and sends the result back to the chat.

About Mongo

Mongo is a community MCP server from kiliczsh, filed in our directory under databases. A Model Context Protocol Server for MongoDB.

Mongo runs on your own machine: your AI app starts it with the command npx -y mcp-mongo-server and talks to it over standard input and output.

At a glance

Publisher
kiliczsh (community)
Runs
Locally on your machine
Install from
Node.js package on npm: mcp-mongo-server
Written in
TypeScript
License
MIT
GitHub stars
282

How to set up Mongo

  1. Install Node.js on the machine that runs your AI app, because Mongo starts with npx and downloads its package on first run.
  2. Check the Mongo README for keys or settings; the registry lists none that Mongo requires.
  3. Add Mongo to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Mongo tools to confirm the connection.
  5. Run one read-only task with Mongo first, and keep your app asking before each tool call until the results look right.

Mongo compared with similar servers

  • OmniFocus by themotionmachine has fewer GitHub stars than Mongo (256 against 282); both are community servers, and both run locally.
  • Pasal by ilhamfp has more GitHub stars than Mongo (290 against 282); both are community servers, and Pasal runs as a remote server and Mongo runs on your own machine.
  • PerformanceStudio by erikdarlingdata has fewer GitHub stars than Mongo (256 against 282); both are community servers, and both run locally.

Before you connect Mongo

  • Give Mongo its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Mongo tool call until you trust what it does with them.
  • Treat text that Mongo fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Mongo on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Mongo

How marketing and sales teams put Mongo to work, by company size. Pick the size closest to yours and start Mongo on one use case.

Small business

  • A small business with its own app can ask Mongo plain questions about customers and orders, without writing SQL.
  • Owners can use Mongo to pull a list of customers who haven't bought in 90 days and plan a win-back email.
  • Mongo runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing analysts can connect Mongo to answer campaign questions from the warehouse directly, instead of waiting on the data team's queue.
  • Lifecycle teams can use Mongo to build audience lists from product data and check counts before a send.
  • Start Mongo on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises should point Mongo at a read replica with a read-only role, so agents query freely without risk to production data.
  • Data teams can expose curated views through Mongo, so marketing gets self-serve answers without access to raw customer tables.
  • Mongo is a community server, so have security review the code and pin a version before Mongo touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Mongo README

From kiliczsh/mcp-mongo-server on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

MCP MongoDB Server

A Model Context Protocol (MCP) server that lets AI assistants work with your MongoDB databases. It exposes your collections, infers their schemas, and runs queries, aggregations, and writes through a standard interface, so tools like Claude Desktop and Cursor can read and reason about your data.

Demo

Why use it

  • Talk to your database in plain language, the assistant discovers your collections and their shape automatically.
  • Read-only mode, restrict write operations globally or per connection.
  • Works everywhere, connects to standalone, replica set, sharded, and Atlas deployments, over plain or TLS connections.

Key Features

  • Read-Only Mode, blocks every write path (insert, update, index creation, and aggregation stages like $out/$merge that could modify data).
  • Smart ObjectId Handling, configurable auto/none/force conversion of 24-character hex strings to ObjectIds.
  • Schema Inference, automatic collection schema detection from document samples.
  • Query & Aggregation, full query and aggregation pipeline support, with optional explain plans.
  • Write Operations, insert, update, and index creation (when read-only mode is off).
  • Time Conversion, a convertTime helper turns Unix timestamps and date strings into UTC/GMT/ISO, so date queries stay unambiguous across timezones.
  • Progress & Cancellation, long operations report progress and can be cancelled mid-flight.
  • Two Transports, run locally over stdio, or expose an HTTP endpoint for remote access.

Requirements

  • Node.js 20 or newer

Quick Start

Point the server at your database, no install step needed:

npx -y mcp-mongo-server mongodb://localhost:27017/mydatabase

Explore safely, without any chance of changing data:

npx -y mcp-mongo-server mongodb://localhost:27017/mydatabase --read-only

Usage

Local (stdio)

This is the default, used by Claude Desktop, Cursor, and other local clients:

npx -y mcp-mongo-server "mongodb://user:pass@localhost:27017/mydatabase"
Remote (HTTP)

Expose an HTTP endpoint at /mcp for remote or multi-client access:

npx -y mcp-mongo-server "mongodb://user:pass@localhost:27017/mydatabase" --transport http --port 3001

By default, only requests without a browser Origin (CLIs, IDEs) and requests from localhost are accepted; everything else is rejected with 403 to guard against DNS-rebinding attacks. Allow specific browser origins with --allowed-origins:

npx -y mcp-mongo-server "mongodb://..." --transport http --port 3001 --allowed-origins "https://app.example.com"
Options
Flag Description
--read-only, -r Block all write operations
--allow-cross-db Allow aggregation $out/$merge/$lookup to target other databases (off by default)
--allow-server-js Allow server-side JavaScript operators $function/$where/$accumulator (off by default)
--transport, -t stdio (default) or http
--port, -p HTTP port (default 3001)
--allowed-origins Comma-separated browser origins to allow in HTTP mode
--json-limit Max HTTP request body size (default 10mb)
--auth-token Require Authorization: Bearer <token> on the HTTP endpoint
Environment Variables
Variable Description
MCP_MONGODB_URI MongoDB connection URI (alternative to the argument)
MCP_MONGODB_CONNECTIONS JSON object of named MongoDB connections and their database permissions
MCP_MONGODB_MAX_RESULT_DOCUMENTS Optional document cap for query and aggregate
MCP_MONGODB_MAX_RESULT_BYTES Optional UTF-8 byte cap for the compact JSON results array, minimum 2
MCP_MONGODB_QUERY_TIMEOUT_MS Optional MongoDB operation timeout in milliseconds for query, aggregate, listIndexes, and query count and explain operations
MCP_MONGODB_READONLY Enable read-only mode ("true")
MCP_MONGODB_ALLOW_CROSS_DB Allow cross-database aggregation stages ("true")
MCP_MONGODB_ALLOW_SERVER_JS Allow server-side JavaScript operators ("true")
MCP_PORT HTTP port
MCP_HTTP_ALLOWED_ORIGINS Comma-separated browser origins to allow in HTTP mode
MCP_HTTP_JSON_LIMIT Max HTTP request body size (default 10mb)
MCP_HTTP_AUTH_TOKEN Bearer token required to access the HTTP endpoint
Named connections

Set MCP_MONGODB_CONNECTIONS to a JSON string. This MCP client configuration uses a local build and the two Docker test databases.

{
  "mcpServers": {
    "mongodb": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-mongo-server/build/index.js"
      ],
      "env": {
        "MCP_MONGODB_CONNECTIONS": "{\"default\":{\"uri\":\"mongodb://127.0.0.1:37017/mcp_test\"},\"analytics\":{\"uri\":\"mongodb://127.0.0.1:37018/mcp_test?directConnection=true\",\"databases\":[\"mcp_test\",\"mcp_test_secondary\"],\"readOnly\":true}}"
      }
    }
  }
}
  • Discover targets with listConnections and listDatabases. Pass connectionId and database to database tools and the collection analysis prompt. Omitted selectors use the default connection and its URI database.
  • Omit databases to allow only the URI database. If supplied, the list must include the URI database. Global read-only mode applies to every connection.
  • Write tools appear in tool discovery when at least one connection is writable. Use listConnections to choose a writable target.
  • A positional URI or MCP_MONGODB_URI can supply default when the JSON contains only secondary connections. Named connections default to a 5-second server selection timeout. Set serverSelectionTimeoutMS in the URI to override it.
  • If a connection is offline, resources/list reports its ID and fails. Tools targeting other connections remain usable.

Security

Database scope. The server operates on the selected database. Named connections restrict selection to their configured databases. Aggregation stages that reach another database ($out, $merge, $lookup with an explicit db) are rejected by default, so a pipeline can't quietly read from or write to databases you didn't point it at. Enable them with --allow-cross-db if you need them. Named connections still enforce their database allowlist.

Server-side JavaScript. The operators $function, $where, and $accumulator are blocked by default in aggregation pipelines and in the filters for query, count, and update. In read-write mode, --allow-server-js enables these operators.

Read-only mode blocks writes, including the $out and $merge aggregation stages. It also blocks server-side JavaScript even when --allow-server-js is set.

Least privilege. Application-level checks only go so far, the strongest guarantee comes from the database. Connect with a MongoDB user scoped to just the database you need, with read-only permissions when the assistant only needs to explore. That way the database itself enforces the boundary, as defense in depth.

Documentation

License

MIT, see LICENSE for details.

Questions about Mongo

What is the Mongo MCP server?

A Model Context Protocol Server for MongoDB. Mongo is maintained by kiliczsh on GitHub at kiliczsh/mcp-mongo-server, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Mongo MCP server?

Add Mongo to your AI app's MCP config with the command npx -y mcp-mongo-server. In Claude Code, run claude mcp add --transport stdio mongo-server -- npx -y mcp-mongo-server. To run Mongo this way you need Node.js installed.

Does Mongo need an API key?

The registry lists no required keys for Mongo. Check the Mongo README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Mongo an official MCP server?

No. Mongo is a community server maintained by kiliczsh. Community servers can be excellent; read the code and the open issues before you give Mongo access to company data.

What license is Mongo under?

Mongo is released under the MIT license, according to its GitHub repository. The license covers the code of Mongo; the service it connects to has its own terms.