MCP Database Server

MCP Database Server

A Model Context Protocol server that enables LLMs to interact with databases (currently MongoDB) through natural language, supporting operations like querying, inserting, deleting documents, and running aggregation pipelines.

manpreet2000

Research & Data
Visit Server

README

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

  1. Clone the repository:
git clone https://github.com/manpreet2000/mcp-database-server.git
cd mcp-database-server
  1. Install dependencies:
npm install
  1. 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/node with your Node.js executable path or just use node
  • /path/to/mcp-database with the absolute path to this repository
  • your-mongodb-connection-string with your MongoDB connection URL

Usage Examples

MongoDB Examples

  1. List all collections in your database:
Can you show me all the collections in my database?
  1. Get specific records from a collection:
Give me 2 records from the chargers collection
  1. Query with filters:
Show me all documents in the users collection where status is active
  1. Insert a document:
Add a new user to the users collection with name John and email john@example.com
  1. Delete a document:
Remove the user with email john@example.com from the users collection
  1. 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 collection
  • limit: Maximum number of documents to return (default: 10, max: 1000)
  • query: MongoDB query object
  • projection: Fields to include/exclude

3. insertOne

Inserts a single document into a collection:

  • collectionName: Name of the collection
  • document: Document object to insert

4. deleteOne

Deletes a single document from a collection:

  • collectionName: Name of the collection
  • query: Query to match the document to delete

5. aggregate

Executes an aggregation pipeline:

  • collectionName: Name of the collection
  • pipeline: Array of aggregation stages
  • options: 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

Recommended Servers

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.

Featured
TypeScript
MCP PubMed Search

MCP PubMed Search

Server to search PubMed (PubMed is a free, online database that allows users to search for biomedical and life sciences literature). I have created on a day MCP came out but was on vacation, I saw someone post similar server in your DB, but figured to post mine.

Featured
Python
dbt Semantic Layer MCP Server

dbt Semantic Layer MCP Server

A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.

Featured
TypeScript
mixpanel

mixpanel

Connect to your Mixpanel data. Query events, retention, and funnel data from Mixpanel analytics.

Featured
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python
Nefino MCP Server

Nefino MCP Server

Provides large language models with access to news and information about renewable energy projects in Germany, allowing filtering by location, topic (solar, wind, hydrogen), and date range.

Official
Python
Vectorize

Vectorize

Vectorize MCP server for advanced retrieval, Private Deep Research, Anything-to-Markdown file extraction and text chunking.

Official
JavaScript
Mathematica Documentation MCP server

Mathematica Documentation MCP server

A server that provides access to Mathematica documentation through FastMCP, enabling users to retrieve function documentation and list package symbols from Wolfram Mathematica.

Local
Python
kb-mcp-server

kb-mcp-server

An MCP server aimed to be portable, local, easy and convenient to support semantic/graph based retrieval of txtai "all in one" embeddings database. Any txtai embeddings db in tar.gz form can be loaded

Local
Python
Research MCP Server

Research MCP Server

The server functions as an MCP server to interact with Notion for retrieving and creating survey data, integrating with the Claude Desktop Client for conducting and reviewing surveys.

Local
Python