MCP Database Server
An MCP server that enables LLMs to interact with databases like MongoDB using natural language.
MCP Database Server
A Model Context Protocol (MCP) server implementation that allows Large Language Models (LLMs) to interact with various databases through natural language. Currently supports MongoDB, with plans to support:
- PostgreSQL
- CockroachDB
- Redis
- And more...
Features
- Database operations through natural language
- Currently supports MongoDB with features:
- List all collections
- Query documents with filtering and projection
- Insert documents
- Delete documents
- Aggregate pipeline operations
- Future support for other databases:
- PostgreSQL: SQL queries, table operations
- CockroachDB: Distributed SQL operations
- Redis: Key-value operations, caching
Prerequisites
- Node.js v20.12.2 or higher
- Database (currently MongoDB, other databases coming soon)
- Claude Desktop Application
Installation
- Clone the repository:
git clone https://github.com/manpreet2000/mcp-database-server.git
cd mcp-database-server
- Install dependencies:
npm install
- Build the TypeScript code:
npm run build
Configuration
To get started, you need to configure your database connection in your Claude Desktop configuration file:
MacOS
~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows
%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"
}
}
}
}
Replace:
/path/to/nodewith your Node.js executable path or just usenode/path/to/mcp-databasewith the absolute path to this repositoryyour-mongodb-connection-stringwith your MongoDB connection URL
Usage Examples
MongoDB Examples
- List all collections in your database:
Can you show me all the collections in my database?
- Get specific records from a collection:
Give me 2 records from the chargers collection
- Query with filters:
Show me all documents in the users collection where status is active
- Insert a document:
Add a new user to the users collection with name John and email john@example.com
- Delete a document:
Remove the user with email john@example.com from the users collection
- Aggregate data:
Show me the total count of users by status in the users collection
Available Tools
1. getCollections
Lists all collections in the connected database.
2. getCollection
Retrieves documents from a collection with optional query parameters:
collectionName: Name of the collectionlimit: Maximum number of documents to return (default: 10, max: 1000)query: MongoDB query objectprojection: Fields to include/exclude
3. insertOne
Inserts a single document into a collection:
collectionName: Name of the collectiondocument: Document object to insert
4. deleteOne
Deletes a single document from a collection:
collectionName: Name of the collectionquery: Query to match the document to delete
5. aggregate
Executes an aggregation pipeline:
collectionName: Name of the collectionpipeline: Array of aggregation stagesoptions: Optional aggregation options
Future Database Support
PostgreSQL
- SQL query execution
- Table operations
- Schema management
- Transaction support
CockroachDB
- Distributed SQL operations
- Multi-region support
- Transaction management
- Schema operations
Redis
- Key-value operations
- Caching mechanisms
- Pub/sub operations
- Data structure operations
Security
- Never commit your database connection strings to version control
- Use environment variables for sensitive information
- Follow database-specific security best practices
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
MIT License - See LICENSE for details
Related Servers
Snowflake MCP Server by CData
A read-only MCP server for querying live Snowflake data, powered by CData.
LoL Data MCP Server
Provides real-time, structured access to League of Legends game data, including champions, items, abilities, game mechanics, and patch information.
GoldRush
Exposes Covalent's GoldRush blockchain data APIs as MCP resources and tools.
PostgreSQL
Provides read-only access to PostgreSQL databases, allowing LLMs to inspect schemas and execute queries.
PawSQL MCP Server
A SQL optimization service providing performance analysis and optimization suggestions through an API.
MCP Memory Dashboard
A desktop application for managing and interacting with the MCP Memory Service, a semantic memory system built on the Model Context Protocol.
CData Reckon Accounts Hosted
A read-only MCP server by CData that enables LLMs to query live data from Reckon Accounts Hosted. Requires a separate CData JDBC Driver.
Canada's Food Guide
A nutrition analysis platform integrating Canada's Food Guide recipes with Health Canada's official nutrition databases.
Google BigQuery by CData
Connect to Google BigQuery databases using CData's MCP Server. Requires a separate CData JDBC Driver license.
OpenDart-MCP
Access the DART (Data Analysis, Retrieval and Transfer System) API for detailed financial information retrieval and analysis.