โœจ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more

MongoDB MCP Server

A Model Context Protocol server that provides read-only access to MongoDB databases through standardized MCP tools and resources.

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 formats

Enhanced 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 description

Requirements

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 databases

Installation

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.

MongoDB Server

Project Details

Recomended MCP Servers

Kubernetes Operations Manager
Kubernetes Operations Manager

kom ๆ˜ฏไธ€ไธช็”จไบŽ Kubernetes ๆ“ไฝœ็š„ๅทฅๅ…ท๏ผŒSDK็บง็š„kubectlใ€client-go็š„ไฝฟ็”จๅฐ่ฃ…ใ€‚ๅนถไธ”ๆ”ฏๆŒไฝœไธบ็ฎก็†k8s ็š„ MCP serverใ€‚ ๅฎƒๆไพ›ไบ†ไธ€็ณปๅˆ—ๅŠŸ่ƒฝๆฅ็ฎก็† Kubernetes ่ต„ๆบ๏ผŒๅŒ…ๆ‹ฌๅˆ›ๅปบใ€ๆ›ดๆ–ฐใ€ๅˆ ้™คๅ’Œ่Žทๅ–่ต„ๆบ๏ผŒ็”š่‡ณไฝฟ็”จSQLๆŸฅ่ฏขk8s่ต„ๆบใ€‚่ฟ™ไธช้กน็›ฎๆ”ฏๆŒๅคš็ง Kubernetes ่ต„ๆบ็ฑปๅž‹็š„ๆ“ไฝœ๏ผŒๅนถ่ƒฝๅคŸๅค„็†่‡ชๅฎšไน‰่ต„ๆบๅฎšไน‰๏ผˆCRD๏ผ‰ใ€‚ ้€š่ฟ‡ไฝฟ็”จ kom๏ผŒไฝ ๅฏไปฅ่ฝปๆพๅœฐ่ฟ›่กŒ่ต„ๆบ็š„ๅขžๅˆ ๆ”นๆŸฅๅ’Œๆ—ฅๅฟ—่Žทๅ–ไปฅๅŠๆ“ไฝœPODๅ†…ๆ–‡ไปถ็ญ‰ๅŠจไฝœใ€‚

SurrealDB MCP Server
SurrealDB MCP Server
๐Ÿงฉ
AppleScript Control

A macOS AppleScript MCP server

Telegram MCP Server
Telegram MCP Server
Ultimate MCP Server
Ultimate MCP Server

The Ultimate Model Context Protocol (MCP) Server, providing unified access to a wide variety of useful and powerful...

๐Ÿงฉ
IcebergMCP
๐Ÿงฉ
TikTok Video Search

A Model Context Protocol service for TikTok video discovery and metadata extraction.

Excel MCP Server
Excel MCP Server

The Excel MCP Server is a powerful tool that enables natural language interaction with Excel files through the...

Browser Use MCP Server
Browser Use MCP Server

Browse the web, directly from Cursor etc.

ODBC SQLAlchemy Server
ODBC SQLAlchemy Server

A simple MCP ODBC server using FastAPI, ODBC and SQLAlchemy.

๐Ÿงฉ
Unichat
bioRxiv MCP Server
bioRxiv MCP Server

๐Ÿ” Enable AI assistants to search and access bioRxiv papers through a simple MCP interface.

Featured Templates

View More

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.