mongo
MCP server that provide tools to LLMs such as claude in cursor to interact with MongoDB
claude mcp add --transport stdio 1rb-mongo-mcp npx mongo-mcp mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin
How to use
This MongoDB MCP Server exposes common MongoDB operations as MCP tools, enabling language models to explore your databases through natural language prompts. By connecting via a simple MCP client configuration, you can query collections, inspect schemas, manage indexes, and perform basic document operations (insert, update, delete) without writing raw MongoDB queries. The server validates inputs and handles errors gracefully, returning structured results that can be consumed by your LLM client.
To use it, point your MCP client (e.g., Claude Desktop or Cursor.ai) to the MongoDB MCP server using the provided connection URL. The server exposes tools such as listCollections, find, insertOne, updateOne, deleteOne, createIndex, dropIndex, and indexes. These tools map directly to common MongoDB operations, allowing you to ask for the schema of a collection, fetch documents with filters, or modify data through natural language prompts. Ensure your MongoDB instance is accessible from where the MCP server runs, and provide credentials with appropriate least-privilege permissions to protect your data.
How to install
Prerequisites:
- Node.js v18 or higher
- npm (comes with Node.js) or pnpm/yarn if you prefer
- Access to a MongoDB instance (local or remote)
Install the MCP server package:
# Install via npm (recommended)
npm install -g @coderay/mongo-mcp-server
Alternatively, install in a local project:
npm install @coderay/mongo-mcp-server
Run the server locally (example):
# Using npx (quick start)
npx mongo-mcp mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin
Or build and run from source if you prefer development mode (assuming repository is cloned):
npm install
npm run build
npm run dev
Additional notes
Notes and tips:
- Use a dedicated MongoDB user with only the necessary read/write permissions for MCP operations.
- Always secure the connection string (avoid embedding credentials in plaintext in shared configs).
- If you run locally behind a firewall, ensure the MCP server can reach the MongoDB host and port.
- For production, consider using TLS/SSL connection strings and enable access controls on both the MCP server and MongoDB.
- The server validates inputs to prevent risky operations; craft queries and operations with prompts that clearly specify collection names and fields.
- If you encounter connection issues, verify the MongoDB URI, network accessibility, and that the MCP server process has the required environment variables set (e.g., for custom configurations).
- When using Docker or Smithery deployments, refer to the platform-specific instructions in the README to ensure proper startup configurations.
Related MCP Servers
mcp-mongo
A Model Context Protocol Server for MongoDB
ls
List MCP Server configurations in your system used by AI applications like Cursor, Claude Desktop, VS Code and others
taskflow
A task management Model Context Protocol (MCP) server that helps AI assistants break down user requests into manageable tasks with subtasks, dependencies, and notes. Enforces a structured workflow with user approval steps.
memory
A MCP (Model Context Protocol) server providing long-term memory for LLMs
mcp-spotify-player
MCP server to manage Spotify from MCP clients
ObsidianMCPServer
A Model Context Protocol (MCP) server that enables AI assistants to interact with your Obsidian vault