kiliczsh/mcp-mongo-server

View on GitHub ↗

A Model Context Protocol Server for MongoDB

283 ★56 forksTypeScriptUpdated 1mo ago

What you need to know

MCP MongoDB Server (mcp-mongo-server) lets AI assistants work directly with MongoDB databases — automatically discovers collections, infers schemas, and runs queries, aggregations, and writes over an MCP interface, with read-only mode, smart ObjectId handling, explain plans, progress, and cancellation.

Install

npx -y mcp-mongo-server mongodb://localhost:27017/mydatabase
Read-only: npx -y mcp-mongo-server mongodb://... --read-only
Remote HTTP: npx -y mcp-mongo-server <uri> --transport http --port 3001

Usage

  • Add the server to Claude Desktop/Cursor; talk to your database in plain language — the assistant discovers collections and their shape automatically
  • Use the convertTime helper to keep date queries unambiguous across timezones
  • Options: --read-only, --allow-cross-db, --allow-server-js, --allowed-origins, --auth-token; env vars MCP_MONGODB_*

Key features

  • Read-only mode blocks every write path including $out/$merge and server-side JS; safe exploration by default
  • Schema inference from document samples, full query & aggregation pipeline support with explain plans, insert/update/index creation
  • Smart ObjectId conversion (auto/none/force), progress reporting and mid-flight cancellation, two transports (stdio + HTTP)
  • Security defaults: cross-db aggregation and server-side JS rejected unless explicitly enabled; HTTPS origin allowlist vs DNS-rebinding

Best for

AI agents and developers who want to explore, query, and (optionally) write to MongoDB via natural language with strong safety defaults.

Caveats

  • Writes only possible when read-only mode is off; cross-DB and server-side JS disabled by default
  • Node.js 20 or newer required
Platforms: macOS · Linux · WindowsClients: Claude Desktop · Cursor · Windsurf · Docker · MCP clients
Documentation ↗

Reviewed 2026-08-11

Topics

antrophicclaudeclaude-desktopclinecursormcpmodel-context-protocolmongomongodbwindsurf
Stars
283★
Forks
56
Language
TypeScript
License
MIT
Created
2024-12-04
Last push
2026-07-29