MongoDB

MongoDB

A Model Context Protocol Server for MongoDB.

269
Stars
50
Forks
10
Releases

Overview

The MCP MongoDB Server is a Model Context Protocol server that enables LLMs to interact with MongoDB databases through a unified interface. It supports inspecting collection schemas and executing a broad set of MongoDB operations, with safe defaults and optional read-only mode. Key features include Smart ObjectId handling with objectIdMode (auto, none, or force); flexible configuration via environment variables (MCP_MONGODB_URI, MCP_MONGODB_READONLY) and CLI options (--read-only); and protection of write operations in read-only mode. It uses MongoDB's secondary read preference to optimize performance when reading. Available operations cover: query (with optional execution plan analysis), aggregate pipelines, and count; and write operations such as update, insert, and createIndex (only when not in read-only mode). LLM integration features include collection completions, schema inference, and collection analysis, which help improve context understanding and interaction. The server includes debugging support via the MCP Inspector, and integrates with Claude Desktop, Windsurf, and Cursor through various configuration approaches (command-line, environment variables, or GitHub package usage). It can be installed globally or developed locally, with scripts for building and auto-reload during development. The README provides examples for usage and deployment.

Details

Owner
kiliczsh
Language
TypeScript
License
MIT License
Updated
2025-12-07

Features

Smart ObjectId Handling

Intelligent conversion between string IDs and MongoDB ObjectId with objectIdMode: auto, none, or force.

Flexible Configuration

Configure MongoDB URI and read-only mode via environment variables (MCP_MONGODB_URI, MCP_MONGODB_READONLY) or CLI options (--read-only).

Read-Only Mode

Protect against write operations (update, insert, createIndex) and use secondary read preference for performance.

Read Operations

Query documents, support execution plan analysis, perform aggregations, and count documents.

Write Operations

Update, insert, and createIndex operations when not in read-only mode.

LLM Integration

Collection completions, schema inference, and collection analysis to improve context and interactions.

Debugging Infrastructure

Debug via MCP Inspector with a dedicated URL for easier troubleshooting.

Claude Desktop & Ecosystem Integration

Configurable via Claude Desktop, Windsurf, and Cursor with CLI, env vars, or GitHub package usage.

Audience

LLM EngineersExpose MongoDB data and operations to language models via a standardized MCP interface.
Data EngineersSafely connect LLMs to production MongoDB with read-only mode and schema insights.
ML IntegratorsIntegrate MCP MongoDB server into Claude/Desktop-like tools for dynamic data access.

Tags

MongoDBMCPLLM integrationSchema inferenceCollection analysisRead-only modeSmart ObjectId handlingQueryAggregateWrite operationsCreateIndexClaude DesktopWindsurfCursor