mcp-mongo-server

kiliczsh/mcp-mongo-server
279 starsMITCommunity

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

A Model Context Protocol Server for MongoDB

README.md

MCP MongoDB Server

---

!NPM Version !NPM Downloads !NPM License ![smithery badge](https://smithery.ai/server/mcp-mongo-server) ![Verified on MseeP](https://mseep.ai/app/e274a3dd-7fe6-4440-8c43-043bae668251)

A Model Context Protocol server that enables LLMs to interact with MongoDB databases. This server provides capabilities for inspecting collection schemas and executing MongoDB operations through a standardized interface.

Demo

![MCP MongoDB Server Demo | Claude Desktop](https://www.youtube.com/watch?v=FI-oE_voCpA)

Key Features

  • Smart ObjectId Handling - Configurable auto/none/force modes for string-to-ObjectId conversion
  • Read-Only Mode - Protection against write operations, uses secondary read preference
  • Schema Inference - Automatic collection schema detection from document samples
  • Query & Aggregation - Full MongoDB query and aggregation pipeline support with optional explain plans
  • Write Operations - Insert, update, and index creation (when not in read-only mode)
  • Collection Completions - Auto-complete collection names for LLM integration

Installation

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

Usage

# Start server with MongoDB URI
npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database

# Connect in read-only mode
npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database --read-only

Environment Variables

| Variable | Description | |----------|-------------| | MCP_MONGODB_URI | MongoDB connection URI | | MCP_MONGODB_READONLY | Enable read-only mode ("true") |

Documentation

License

MIT - see LICENSE for details.

Related MCP servers

Browse all →