The MCP Database Server allows Large Language Models (LLMs) to interact with various databases through natural language. It currently supports MongoDB with plans to expand to PostgreSQL, CockroachDB, Redis, and others, enabling you to perform database operations simply by describing what you want in plain English.
git clone https://github.com/manpreet2000/mcp-database-server.git
cd mcp-database-server
npm install
npm run build
You need to configure your database connection in your Claude Desktop configuration file:
~/Library/Application\ Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
Add the following configuration to your claude_desktop_config.json
:
{
"mcpServers": {
"database": {
"command": "/path/to/node",
"args": ["/path/to/mcp-database/dist/index.js"],
"env": {
"MONGODB_URI": "your-mongodb-connection-string"
}
}
}
}
Be sure to replace:
/path/to/node
with your Node.js executable path or just use node
/path/to/mcp-database
with the absolute path to this repositoryyour-mongodb-connection-string
with your MongoDB connection URLYou can interact with your database by asking Claude questions in natural language:
Can you show me all the collections in my database?
Give me 2 records from the chargers collection
Show me all documents in the users collection where status is active
Add a new user to the users collection with name John and email [email protected]
Remove the user with email [email protected] from the users collection
Show me the total count of users by status in the users collection
The server supports these MongoDB operations:
When retrieving documents, you can specify:
For data analysis, you can run aggregation pipelines with:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.