MongoDB
About
Enables querying and analyzing MongoDB databases with read-only access, providing operations for exploration, schema inference, querying, aggregation, text search, and geospatial analysis.
Details
- Author
- jonfreeland
- Repository
- jonfreeland/mongodb-mcp
- GitHub stars
- 7
- Downloads
- 188
- License
- MIT License
- Categories
- Database, Other, AI, Design, Developer Tools, Search, Infrastructure, Frontend
Jump to
- Schema Inference: Automatically detect data types and structure from documents
- Visualization Hints: Intelligent suggestions for data visualization based on result content
- Safety Validation: Prevents write operations in aggregation pipelines
- Example-Rich Documentation: Each tool includes detailed examples in its description
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MongoDBCommand (node, npx, python, etc.)nodeArguments-
Argument 1
/path/to/mongodb-server/build/index.js
Environment-
MONGODB_URI
mongodb://username:password@hostname:port/database -
MONGODB_DEFAULT_DATABASE
your_default_db
Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
-
Argument 1
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
- MONGODB_URI (required): MongoDB connection string with authentication if needed
- MONGODB_DEFAULT_DATABASE (optional): Default database name when not specified in queries
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mongodb": {
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
},
"args": [
"/path/to/mongodb-server/build/index.js"
],
"command": "node"
}
}
}
Linux
{
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
},
"args": [
"/path/to/mongodb-server/build/index.js"
],
"command": "node"
}
Macos
{
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
},
"args": [
"/path/to/mongodb-server/build/index.js"
],
"command": "node"
}
Windows
{
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
},
"args": [
"/path/to/mongodb-server/build/index.js"
],
"command": "node"
}
MongoDB MCP Server
A Model Context Protocol server that provides read-only access to MongoDB databases through standardized MCP tools and resources.
<a href="https://glama.ai/mcp/servers/cmywezu1sn">
</a>
Overview
This MongoDB MCP server enables AI assistants to directly query and analyze MongoDB databases without write access, maintaining data safety while providing powerful data exploration capabilities.
Features
MongoDB Operations
- Database Exploration: List databases and collections - Schema Discovery: Infer collection schemas from sample documents - Querying: Execute MongoDB queries with filtering, projection, sorting, and limiting - Aggregation: Run read-only aggregation pipelines with safety validation - Text Search: Perform full-text search on collections with text indexes - Geospatial Queries: Find locations near points, within polygons, or intersecting geometries - Document Operations: Count documents, sample random documents, find documents by IDs - Data Analysis: Get collection statistics, index information, and query execution plans - Performance Insights: Examine query execution plans to optimize performance - Data Exploration: Get distinct values, field distributions, and data samples - Format Conversion: Export query results as JSON or CSV formatsEnhanced Capabilities
- Schema Inference: Automatically detect data types and structure from documents - Visualization Hints: Intelligent suggestions for data visualization based on result content - Safety Validation: Prevents write operations in aggregation pipelines - Example-Rich Documentation: Each tool includes detailed examples in its descriptionRequirements
Environment Variables
-MONGODB_URI (required): MongoDB connection string with authentication if needed
- MONGODB_DEFAULT_DATABASE (optional): Default database name when not specified in queries
Prerequisites
- Network access to MongoDB server - Authentication credentials if required by MongoDB instance - Appropriate read permissions on target databasesInstallation
Building from Source
Install dependencies:
npm install
Build the server:
npm run build
For development with auto-rebuild:
npm run watch
Integration with Claude Desktop
To use with Claude Desktop, add the server configuration:
On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "/path/to/mongodb-server/build/index.js",
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
}
}
}
}
Integration with Claude Web
For Claude Web via the MCP Chrome extension, add configuration to Cline MCP settings:
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": ["/path/to/mongodb-server/build/index.js"],
"env": {
"MONGODB_URI": "mongodb://username:password@hostname:port/database",
"MONGODB_DEFAULT_DATABASE": "your_default_db"
}
}
}
}
Integration with Claude Code
To use with Claude Code, use the following commands:
cd /path/to/my/project
claude mcp add mongo-server /path/to/mongodb-mcp/build/index.js -e "MONGODB_URI=mongodb://user@password:27017/dbname?authSource=authDbName" -e MONGO_DEFAULT_DATABASE=dbname
Make sure to replace the placeholders with your actual MongoDB connection string and default database name.
If configured correctly, you should see the following when you run claude:
╭───────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
│ │
│ /help for help │
│ │
│ cwd: <path-to-project-directory> │
│ │
│ ─────────────────────────────────────────────────── │
│ │
│ MCP Servers: │
│ │
│ • mongo-server connected │
╰───────────────────────────────────────────────────────╯
If you run into issues, see the Claude Code documentation.
Security Considerations
- This server provides read-only access by design
- Connection strings may contain sensitive authentication information
- Store connection strings securely in environment variables
- Use a MongoDB user with read-only permissions
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. Use the MCP Inspector, which is available as a package script:
npm run inspector
The Inspector will provide a URL to access debugging tools in your browser.29:["$","div",null,{"className":"my-8 pb-8 h-full max-w-5xl mx-auto","children":["$","div",null,{"className":"grid grid-cols-1 md:grid-cols-3 gap-6","children":["$","$L30",null,{"mcp":{"id":"mcp_3AihpOoolxzT","name":"MongoDB","description":"Enables querying and analyzing MongoDB databases with read-only access, providing operations for exploration, schema inference, querying,
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





