mongodb
A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.
claude mcp add --transport stdio mongodb-js-mongodb-mcp-server npx -y mongodb-mcp-server@latest --readOnly \ --env MDB_MCP_CONNECTION_STRING="mongodb://localhost:27017/myDatabase"
How to use
This MongoDB MCP Server exposes a model-contextful interface to your MongoDB databases and MongoDB Atlas using the MCP (Model Context Protocol). It supports a suite of MongoDB-focused tools, including Atlas API access for service accounts, and database operations via a read-only (default) configuration. Clients can connect using a configuration object (for example, from Windsurf, Cursor, or VSCode MCP integrations) that specifies the server command (npx in this case), the package to run (mongodb-mcp-server), and optional environment variables such as the MongoDB connection string or Atlas API credentials. The server can then be accessed to inspect databases, collections, documents, and perform safe, read-only queries. If you need write access, remove the --readOnly flag in the configuration.
How to install
Prerequisites:
- Node.js (recommended: v20.x or higher). Verify with: node -v
- Access to a MongoDB instance or Atlas API credentials if you plan to use Atlas features.
Step-by-step installation:
# 1) Ensure Node.js is installed
node -v
# 2) Create a configuration file for MCP (example: mcp_config.json) using the settings below
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"
}
}
}
}
# 3) Run the MCP server using the configuration. If your client expects a JSON config, pass it to the MCP launcher accordingly. An example (inline) usage with npx is:
npx -y mongodb-mcp-server@latest --readOnly
# 4) Alternatively, you can use a config file with a launcher that your MCP client supports ( Windsurf, Cursor, VSCode, etc. ) depending on your setup.
Notes:
- The README examples show using the MongoDB MCP Server via npx with a readOnly mode by default. You can adjust the args to enable write operations if needed by removing --readOnly and by supplying appropriate credentials.
- If you plan to connect to Atlas, supply MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET in env in addition to MDB_MCP_CONNECTION_STRING as needed.
Additional notes
Tips and common considerations:
- By default, the configuration uses --readOnly to ensure safe data access. Remove this flag only if your MCP client and security model require write operations.
- Store sensitive information (connection strings, API credentials) in environment variables rather than command line arguments to reduce exposure in process lists and logs.
- For Atlas API access, create a service account in MongoDB Atlas and use MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET for authentication.
- The exact invocation method may vary by MCP client (Windsurf, Cursor, VSCode, etc.). Adapt the launcher command to your client’s expected config format (e.g., a mcp.json file or environment-driven launcher).
- Ensure the Node.js version is compatible with mongodb-mcp-server and the MCP client tooling you use (Node 20.x+ is generally recommended).
Related MCP Servers
context7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
obsidian -tools
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
MiniMax -JS
Official MiniMax Model Context Protocol (MCP) JavaScript implementation that provides seamless integration with MiniMax's powerful AI capabilities including image generation, video generation, text-to-speech, and voice cloning APIs.
mcp-bundler
Is the MCP configuration too complicated? You can easily share your own simplified setup!
mongo
MCP server that provide tools to LLMs such as claude in cursor to interact with MongoDB
akyn-sdk
Turn any data source into an MCP server in 5 minutes. Build AI-agents-ready knowledge bases.