MongoDB MCP Server for LLMs

MongoDB MCP Server for LLMs

mongo-mcp-1rb•by1rb

An MCP server that lets LLMs query MongoDB collections, inspect schemas, manage indexes, and perform document operations through exposed tools.

License: MIT License•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Lists available collections and queries documents with filtering and projection.
  • •Inserts, updates, and deletes individual documents in collections.
  • •Creates, drops, and lists indexes on collections.
  • •Validates inputs with Zod and connects to MongoDB using a provided connection string.

BEST FOR

  • •Asking an LLM client to inspect a MongoDB database's collections and schemas.
  • •Running filtered queries against MongoDB data through natural language.
  • •Managing MongoDB indexes and documents conversationally.

ABOUT MONGO-MCP-1RB

MongoDB MCP Server for LLMs is cataloged as an MCP server attributed to 1rb. An MCP server that lets LLMs query MongoDB collections, inspect schemas, manage indexes, and perform document operations through exposed tools. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MongoDB MCP Server for LLMs are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What MongoDB tools does this server expose?

It provides query tools (listCollections, find, insertOne, updateOne, deleteOne) and index tools (createIndex, dropIndex, indexes).

How does the server connect to MongoDB?

It connects using a MongoDB connection string provided in the configuration.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 4a5b1c0a0101 · 采集于 2026-11-13 10:05:11 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

🗄️ MongoDB MCP Server for LLMS

Node.js 18+ License: MIT npm version smithery badge

A 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.

📚 What is Model Context Protocol (MCP)?

The Model Context Protocol (MCP) is an open standard developed by Anthropic that creates a universal way for AI systems to connect with external data sources and tools. MCP establishes a standardized communication channel between:

  • MCP Clients: AI assistants like Claude that consume data (e.g., Claude Desktop, Cursor.ai)
  • MCP Servers: Services that expose data and functionality (like this MongoDB server)

Key benefits of MCP:

  • Universal Access: Provides a single protocol for AI assistants to query data from various sources
  • Standardized Connections: Handles authentication, usage policies, and data formats consistently
  • Sustainable Ecosystem: Promotes reusable connectors that work across multiple LLM clients

✨ Features

  • 🔍 Collection schema inspection
  • 📊 Document querying and filtering
  • 📈 Index management
  • 📝 Document operations (insert, update, delete)
  • 🔒 Secure database access through connection strings
  • 📋 Comprehensive error handling and validation

📋 Prerequisites

Before you begin, ensure you have:

You can verify your Node.js installation by running:

node --version  # Should show v18.0.0 or higher

🚀 Quick Start

To get started, find your MongoDB connection URL and add this configuration to your Claude Desktop config file:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "mongo-mcp",
        "mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
      ]
    }
  }
}

Installing via Smithery

Smithery.ai is a registry platform for MCP servers that simplifies discovery and installation. To install MongoDB MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mongo-mcp --client claude

Cursor.ai Integration

To use MongoDB MCP with Cursor.ai:

  1. Open Cursor.ai and navigate to Settings > Features
  2. Look for "MCP Servers" in the features panel
  3. Add a new MCP server with the following configuration:
    • Name: mongodb
    • Command: npx
    • Args: mongo-mcp mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin

Note: Cursor currently supports MCP tools only in the Agent in Composer feature.

Test Sandbox Setup

If you don't have a MongoDB server to connect to and want to create a sample sandbox, follow these steps:

  1. Start MongoDB using Docker Compose:
docker-compose up -d
  1. Seed the database with test data:
npm run seed

Configure Claude Desktop

Add this configuration to your Claude Desktop config file:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

Local Development Mode:

{
  "mcpServers": {
    "mongodb": {
      "command": "node",
      "args": [
        "dist/index.js",
        "mongodb://root:example@localhost:27017/test?authSource=admin"
      ]
    }
  }
}

Test Sandbox Data Structure

The seed script creates three collections with sample data:

Users

  • Personal info (name, email, age)
  • Nested address with coordinates
  • Arrays of interests
  • Membership dates

Products

  • Product details (name, SKU, category)
  • Nested specifications
  • Price and inventory info
  • Tags and ratings

Orders

  • Order details with items
  • User references
  • Shipping and payment info
  • Status tracking

🎯 Example Prompts

Try these prompts with Claude to explore the functionality:

Basic Operations

"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"

Advanced Queries

"Find all electronics products that are in stock and cost less than $1000"
"Show me all orders from the user john@example.com"
"List the products with ratings above 4.5"

Index Management

"What indexes exist on the users collection?"
"Create an index on the products collection for the 'category' field"
"List all indexes across all collections"

Document Operations

"Insert a new product with name 'Gaming Laptop' in the products collection"
"Update the status of order with ID X to 'shipped'"
"Find and delete all products that are out of stock"

📝 Available Tools

The server provides these tools for database interaction:

Query Tools

  • listCollections: Lists available collections in the database
  • find: Queries documents with filtering and projection
  • insertOne: Inserts a single document into a collection
  • updateOne: Updates a single document in a collection
  • deleteOne: Deletes a single document from a collection

Index Tools

  • createIndex: Creates a new index on a collection
  • dropIndex: Removes an index from a collection
  • indexes: Lists indexes for a collection

🛠️ Development

This project is built with:

  • TypeScript for type-safe development
  • MongoDB Node.js driver for database operations
  • Zod for schema validation
  • Model Context Protocol SDK for server implementation

To set up the development environment:

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

🔒 Security Considerations

When using this MCP server with your MongoDB database:

  1. Create a dedicated MongoDB user with minimal permissions needed for your use case
  2. Never use admin credentials in production environments
  3. Enable access logging for audit purposes
  4. Set appropriate read/write permissions on collections
  5. Use connection string parameters to restrict access (e.g., readPreference=secondary)
  6. Consider IP allow-listing to restrict database access

⚠️ IMPORTANT: Always follow the principle of least privilege when configuring database access.

🌐 How It Works

The MongoDB MCP server:

  1. Connects to your MongoDB database using the connection string provided
  2. Exposes MongoDB operations as tools that follow the MCP specification
  3. Validates inputs using Zod for type safety and security
  4. Executes queries and returns structured data to the LLM client
  5. Manages connection pooling and proper error handling

All operations are executed with proper validation to prevent security issues such as injection attacks.

📦 Deployment

You can deploy this MCP server in several ways:

  • Locally via npx (as shown in Quick Start)
  • As a global npm package: npm install -g @coderay/mongo-mcp-server
  • In a Docker container (see Dockerfile in the repository)
  • As a service on platforms like Heroku, Vercel, or AWS

❓ Troubleshooting

Common Issues

  1. Connection Errors

    • Verify your MongoDB connection string is correct
    • Check that your MongoDB server is running and accessible
    • Ensure network permissions allow the connection
  2. Authentication Issues

    • Confirm username and password are correct
    • Verify the authentication database is specified (usually authSource=admin)
    • Check if MongoDB requires TLS/SSL connections
  3. Tool Execution Problems

    • Restart Claude Desktop or Cursor.ai completely
    • Check the logs for detailed error messages:
      # macOS
      tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
      
  4. Performance Issues

    • Consider adding appropriate indexes to frequently queried fields
    • Use projection to limit the data returned in queries
    • Use limit and skip parameters for pagination

Getting Help

If you encounter issues:

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MongoDB MCP Server for LLMs from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mongo-mcp-1rb)

REPOSITORY STATS

GitHub Stars15
Forks9

GitHub API evidence checked 2026-11-25 00:11:00.413Z (UTC). Repository-level counts are shared by all components, not individual server installs. Open issues including pull requests: 3.

Last repository push (UTC):2025-03-11

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage