home / mcp / mcp mongodb server
A Model Context Protocol Server for MongoDB
Configuration
View docs{
"mcpServers": {
"kiliczsh-mcp-mongo-server": {
"command": "npx",
"args": [
"-y",
"mcp-mongo-server",
"mongodb://localhost:27017/database"
],
"env": {
"MCP_MONGODB_URI": "mongodb://localhost:27017/database",
"MCP_MONGODB_READONLY": "true"
}
}
}
}You can run an MCP MongoDB Server to let large language models interact with your MongoDB data. It can inspect collection schemas, execute MongoDB operations, and offer read-only or full write capabilities through a standardized interface, making it easier to explore, query, and manage your data from LLM-powered tools.
Start the MCP MongoDB Server by providing the MongoDB connection URI to the server. You can run in normal mode or in read-only mode to prevent write operations. Use the server to perform schema inference, queries, aggregations, inserts, updates, and index creation through a consistent interface.
Prerequisites: ensure Node.js and npm are installed on your system. You should have network access to reach your MongoDB instance.
# Start the MCP MongoDB Server against a local MongoDB instance
npx -y mcp-mongo-server mongodb://localhost:27017/databaseEnvironment variables supported by the server let you configure the connection behavior. You can enable read-only mode to protect data and rely on a read preference to read from secondaries if available.
If you want to run a read-only session, use the same start command with the read-only flag.
Configurable auto/none/force modes for string-to-ObjectId conversion during operations.
Protection against write operations with read-preference optimization.
Automatic detection of collection schemas from document samples.
Full MongoDB query and aggregation pipeline support with optional explain plans.
Support for insert, update, and index creation when not in read-only mode.
Auto-complete collection names to assist LLM integration.