MongoDB MCP Server config
Add this to your MCP client's config, or use the install line.
Part of MongoDB MCP Server by Admin
claude mcp add-json mongodb '{"command":"npx","args":["-y","mongodb-mcp-server@latest","--readOnly"],"env":{"MDB_MCP_CONNECTION_STRING":"mongodb://localhost:27017/myDatabase"}}'
Check it before you connect it. An MCP server runs with your permissions. Replace placeholder keys with your own and never share them.
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"
}
}
}
}