MCP MongoDB Server (v2.0.2) is a Model Context Protocol (MCP) server that enables LLMs like Claude to interact with MongoDB databases. It provides tools for inspecting schemas, running queries and aggregations, and performing write operations (inserts, updates, index creation) with configurable read-only mode. Key differentiators include smart ObjectId conversion (auto/none/force), automatic schema inference, and collection name auto-completions for LLMs. Released on npm with active development, it supports the growing MCP ecosystem for AI-assisted database operations.
npm install mcp-mongo-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Starts the MCP MongoDB server in read-only mode. Shows how to run the CLI and configure an MCP client (like Claude Desktop) to connect.
Use npx -y mcp-mongo-server instead of npx mcp-mongo.
Replace --dry-run with --read-only in CLI arguments and MCP_MONGODB_DRY_RUN env var with MCP_MONGODB_READONLY.
Pass --read-only flag or set MCP_MONGODB_READONLY=true to restrict to read-only operations.
Use --object-id-handler=force (CLI) or set MCP_MONGODB_OBJECTID_HANDLER=force to always convert string _id to ObjectId.
Replace MCP_MONGODB_DRY_RUN with MCP_MONGODB_READONLY=true in your environment configuration.
Pass the URI as an argument: npx -y mcp-mongo-server mongodb://localhost:27017/mydb
Start your MongoDB instance or verify the host/port in the URI. If using a different host (e.g., 127.0.0.1 vs localhost), specify it explicitly.
Ensure the URI follows the standard mongodb://[user:pass@]host[:port]/database format. Escape special characters in password if present.