Integrations
Provides access to MongoDB databases, allowing LLMs to inspect collection schemas and execute MongoDB operations like queries, aggregations, updates, inserts, and creating indexes
MCP MongoDB Server
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
Key Features
Smart ObjectId Handling
- Intelligent conversion between string IDs and MongoDB ObjectId
- Configurable with
objectIdMode
parameter:"auto"
: Convert based on field names (default)"none"
: No conversion"force"
: Force all string ID fields to ObjectId
Flexible Configuration
- Environment Variables:
MCP_MONGODB_URI
: MongoDB connection URIMCP_MONGODB_READONLY
: Enable read-only mode when set to "true"
- Command-line Options:
--read-only
or-r
: Connect in read-only mode
Read-Only Mode
- Protection against write operations (update, insert, createIndex)
- Uses MongoDB's secondary read preference for optimal performance
- Ideal for safely connecting to production databases
MongoDB Operations
- Read Operations:
- Query documents with optional execution plan analysis
- Execute aggregation pipelines
- Count documents matching criteria
- Get collection schema information
- Write Operations (when not in read-only mode):
- Update documents
- Insert new documents
- Create indexes
LLM Integration
- Collection completions for enhanced LLM interaction
- Schema inference for improved context understanding
- Collection analysis for data insights
Installation
Global Installation
For Development
Usage
Basic Usage
Environment Variables
You can configure the server using environment variables, which is particularly useful for CI/CD pipelines, Docker containers, or when you don't want to expose connection details in command arguments:
Using environment variables in Claude Desktop configuration:
Using environment variables with Docker:
Integration with Claude Desktop
Manual Configuration
Add the server configuration to Claude Desktop's config file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Command-line Arguments Approach:
Environment Variables Approach:
GitHub Package Usage:
Integration with Windsurf and Cursor
The MCP MongoDB Server can be used with Windsurf and Cursor in a similar way to Claude Desktop.
Windsurf Configuration
Add the server to your Windsurf configuration:
Cursor Configuration
For Cursor, add the server configuration to your settings:
You can also use the environment variables approach with both Windsurf and Cursor, following the same pattern shown in the Claude Desktop configuration.
Automated Installation
Using Smithery:
Using mcp-get:
Available Tools
Query Operations
- query: Execute MongoDB queriesCopy
- aggregate: Run aggregation pipelinesCopy
- count: Count matching documentsCopy
Write Operations
- update: Modify documentsCopy
- insert: Add new documentsCopy
- createIndex: Create collection indexesCopy
System Operations
- serverInfo: Get MongoDB server detailsCopy
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. Use the MCP Inspector for better visibility:
This will provide a URL to access the debugging tools in your browser.
Running evals
The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.
License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
You must be authenticated.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
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.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.Last updated -34075TypeScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides read-only access to MongoDB databases, enabling AI assistants to directly query and analyze MongoDB data while maintaining data safety.Last updated -1492JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340MIT License