Home / MCP / Database MCP Server
Provides natural language access to MongoDB via an MCP server with CRUD and aggregation capabilities.
Configuration
View docs{
"mcpServers": {
"database": {
"command": "/path/to/node",
"args": [
"/path/to/mcp-database/dist/index.js"
],
"env": {
"MONGODB_URI": "your-mongodb-connection-string"
}
}
}
}You have an MCP server that enables large language models to interact with MongoDB using natural language, with the ability to list collections, query and modify documents, and run aggregations. This makes it easy to ask your model to perform common database tasks without writing SQL or MongoDB queries directly.
You connect your MCP client to the database server to enable natural language interactions with MongoDB. You can perform the following operations through simple, human language prompts:
Prerequisites and environment setup ensure you can run the MCP server locally and connect to MongoDB.
Step 1: Install prerequisites and verify versions - Node.js v20.12.2 or higher - MongoDB instance accessible to the MCP server - Claude Desktop Application (for configuration and workflow integration)
Step 2: Clone the project and install dependencies
```
git clone https://github.com/manpreet2000/mcp-database-server.git
cd mcp-database-server
npm installStep 3: Build the TypeScript sources
```
npm run buildConfigure your Claude Desktop client to run the MCP server locally and connect to MongoDB. Use the following example configuration snippet to set up the server integration.
{
"mcpServers": {
"database": {
"command": "/path/to/node",
"args": ["/path/to/mcp-database/dist/index.js"],
"env": {
"MONGODB_URI": "your-mongodb-connection-string"
}
}
}
}Never expose your MongoDB connection string publicly. Use environment variables for sensitive information and follow database-specific security best practices.
If you encounter connection issues, verify that the MongoDB URI is correct and that the MongoDB instance allows connections from the MCP server host. Check that the server process has the necessary permissions to access the specified dist/index.js and that Node.js is available at the path you configured.
Lists all collections in the connected database.
Retrieves documents from a specific collection with optional query, limit, and projection parameters.
Inserts a single document into a specified collection.
Deletes a single document from a collection based on a query.
Executes an aggregation pipeline on a collection with optional options.