# kiliczsh/mcp-mongo-server [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/kiliczsh/mcp-mongo-server  
**GitHub Stars:** 283  
**npm Downloads (last month):** 814  
**Views:** 4  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/kiliczsh-mcp-mongo-server

## Description
A Model Context Protocol Server for MongoDB

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "mcp-mongo-server": {
    "command": "npx",
    "args": ["-y","mcp-mongo-server"],
    "env": {
      "MCP_MONGODB_URI": "",
      "MCP_MONGODB_READONLY": "",
      "MCP_MONGODB_ALLOW_CROSS_DB": "",
      "MCP_MONGODB_ALLOW_SERVER_JS": "",
      "MCP_PORT": "",
      "MCP_HTTP_ALLOWED_ORIGINS": "",
      "MCP_HTTP_JSON_LIMIT": "",
      "MCP_HTTP_AUTH_TOKEN": ""
    }
  }
}
```

**Requires environment variables:** `MCP_MONGODB_URI`, `MCP_MONGODB_READONLY`, `MCP_MONGODB_ALLOW_CROSS_DB`, `MCP_MONGODB_ALLOW_SERVER_JS`, `MCP_PORT`, `MCP_HTTP_ALLOWED_ORIGINS`, `MCP_HTTP_JSON_LIMIT`, `MCP_HTTP_AUTH_TOKEN` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What kiliczsh/mcp-mongo-server MCP server does

kiliczsh/mcp-mongo-server MCP server gives MCP-compatible AI clients access to a MongoDB database selected by the connection URI. It can inspect collections, infer their schemas from sampled documents, run queries, execute aggregation pipelines, and optionally explain query plans. When read-only mode is disabled, the available database operations also include inserts, updates, and index creation.

The server is intended for the 🗄️ Databases category and is useful when an assistant needs to inspect or operate on MongoDB data through a standard tool interface. It supports standalone MongoDB instances, replica sets, sharded deployments, and Atlas connections over plain or TLS connections.

## How it works

The process receives a MongoDB URI as a command-line argument or through `MCP_MONGODB_URI`. By default, it communicates with local MCP clients over stdio. Claude Desktop and Cursor use this mode, and the documentation also covers Windsurf integration. An HTTP transport is available at `/mcp` for remote or multi-client use.

Schema discovery happens automatically from document samples. Query and aggregation operations support MongoDB syntax, with optional query explanation. A `convertTime` helper converts Unix timestamps and date strings into UTC, GMT, or ISO formats for clearer date handling across time zones. Long-running operations can report progress and accept cancellation.

## Setup and configuration

kiliczsh/mcp-mongo-server MCP server requires Node.js 20 or newer. The quickest start uses `npx` with a MongoDB URI:

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

Add `--read-only` when the client should be prevented from changing data. For HTTP mode, select `--transport http` and optionally set `--port`, `--allowed-origins`, `--json-limit`, and `--auth-token`. HTTP requests without a browser Origin and requests from localhost are accepted by default; other browser origins must be explicitly allowed.

The corresponding environment variables include `MCP_MONGODB_URI`, `MCP_MONGODB_READONLY`, `MCP_PORT`, `MCP_HTTP_ALLOWED_ORIGINS`, `MCP_HTTP_JSON_LIMIT`, and `MCP_HTTP_AUTH_TOKEN`. Cross-database aggregation and server-side JavaScript are disabled by default and can be enabled with `--allow-cross-db` and `--allow-server-js`, or their environment-variable equivalents.

## Tools and capabilities

The kiliczsh/mcp-mongo-server MCP server supports:

- Collection discovery and schema inference from sampled documents.
- MongoDB queries and aggregation pipelines.
- Optional query and aggregation explain plans.
- Inserts, updates, and index creation when writes are enabled.
- Read-only enforcement across direct writes and modifying aggregation stages such as `$out` and `$merge`.
- Configurable conversion of 24-character hexadecimal strings to MongoDB `ObjectId` values using `auto`, `none`, or `force` behavior.
- Progress reporting and cancellation for long operations.

## Limitations and notes

The server operates on the database named in its connection string. Cross-database `$out`, `$merge`, and `$lookup` targets are rejected unless explicitly enabled. MongoDB server-side JavaScript operators including `$function`, `$where`, and `$accumulator` are also blocked by default. Read-only mode blocks these operators as well as all supported write paths.

Application-level restrictions should be backed by MongoDB permissions. The README recommends using a database user limited to the required database, with read-only permissions when data exploration is the only need. The project is licensed under MIT.

_Full upstream README: https://allmcps.com/mcp/kiliczsh-mcp-mongo-server/readme_

