🗄️ mcp-database-server
Connect any LLM to 22 databases in seconds.
> One MCP server. Every database you'll ever need. Secure by default. Zero boilerplate.
Built on the Model Context Protocol (MCP) — the open standard that lets AI assistants talk to your databases safely.```
┌──────────────┐ ┌─────────────────────────┐ ┌──────────────────┐
│ │ │ │ │ PostgreSQL │
│ Claude / │◄────►│ mcp-database-server │◄────►│ MySQL │
│ Any LLM │ MCP │ │ │ MongoDB │
│ │ │ • Security Layer │ │ Redis │
│ │ │ • Rate Limiting │ │ ... 18 more │
└──────────────┘ │ • Audit Logging │ └──────────────────┘
└─────────────────────────┘
---
## 📑 Table of Contents
- What Does This Do?
- Supported Databases
- Installation
- Quick Start (5 minutes)
- Setup with Claude Desktop
- Setup with Claude Code
- Setup with Config File
- All MCP Tools Reference
- **Database Guides** (click any to jump):
- PostgreSQL
- MySQL
- MariaDB
- SQLite
- Microsoft SQL Server
- Oracle
- CockroachDB
- Neon (Serverless Postgres)
- Supabase
- PlanetScale
- TiDB
- SingleStore
- MongoDB
- Redis
- Cassandra / ScyllaDB
- ClickHouse
- Neo4j
- DynamoDB
- Elasticsearch / OpenSearch
- CouchDB
- InfluxDB
- Firestore
- Security
- Environment Variables Reference
- Troubleshooting
- Publishing to NPM
- Architecture
- License
---
## 🤔 What Does This Do?
Imagine you could say to Claude:
> *"Show me all users who signed up last week"*
...and Claude actually queries your PostgreSQL database, gets the results, and shows you the data. That's what this does.
**Without this tool**, Claude has no way to talk to your databases.
**With this tool**, Claude can:
- ✅ Run queries on any of your databases
- ✅ Explore tables and schemas
- ✅ Understand your data model (columns, types, foreign keys)
- ✅ Work across multiple databases at once
- ✅ Do it all securely (read-only mode, injection protection, rate limits, audit logs)
---
## 🎯 Supported Databases (22)
| # | Database | Category | NPM Driver to Install |
|---|----------|----------|-----------------------|
| 1 | **PostgreSQL** | Relational | `npm install pg` |
| 2 | **MySQL** | Relational | `npm install mysql2` |
| 3 | **MariaDB** | Relational | `npm install mysql2` |
| 4 | **SQLite** | Relational | `npm install better-sqlite3` |
| 5 | **MS SQL Server** | Relational | `npm install tedious` |
| 6 | **Oracle** | Relational | `npm install oracledb` |
| 7 | **CockroachDB** | NewSQL | `npm install pg` |
| 8 | **Neon** | Serverless Postgres | `npm install pg` |
| 9 | **Supabase** | BaaS (Postgres) | `npm install pg` |
| 10 | **PlanetScale** | Serverless MySQL | `npm install mysql2` |
| 11 | **TiDB** | NewSQL | `npm install mysql2` |
| 12 | **SingleStore** | NewSQL | `npm install mysql2` |
| 13 | **MongoDB** | Document | `npm install mongodb` |
| 14 | **Redis** | Key-Value | `npm install redis` |
| 15 | **Cassandra** / ScyllaDB | Wide Column | `npm install cassandra-driver` |
| 16 | **ClickHouse** | Analytics | `npm install @clickhouse/client` |
| 17 | **Neo4j** | Graph | `npm install neo4j-driver` |
| 18 | **DynamoDB** | AWS Key-Value | `npm install @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb` |
| 19 | **Elasticsearch** / OpenSearch | Search | `npm install @elastic/elasticsearch` |
| 20 | **CouchDB** | Document | `npm install nano` |
| 21 | **InfluxDB** | Time Series | `npm install @influxdata/influxdb-client` |
| 22 | **Firestore** | Google Cloud Document | `npm install firebase-admin` |
> **Important:** You only install drivers for databases you actually use. Don't install all of them!
---
## 📦 Installation
### Step 1: Install the server```bash
npm install -g mcp-database-server
Step 2: Install ONLY the database driver(s) you need
Using PostgreSQL? Install pg:```bash
npm install -g pg
Using MongoDB? Install `mongodb`:```bash
npm install -g mongodb
Using multiple databases? Install multiple:```bash
npm install -g pg mongodb redis
That's it. You're ready.
---
## 🚀 Quick Start (5 minutes)
The fastest way to try it out:
### Option A: Environment Variables (simplest)```bash
# Set your database details
export MCP_DB_ENGINE=postgresql
export MCP_DB_HOST=localhost
export MCP_DB_PORT=5432
export MCP_DB_DATABASE=myapp
export MCP_DB_USER=postgres
export MCP_DB_PASSWORD=mypassword
# Run the server
npx mcp-database-server
Option B: Connection String (one line)```bash
export MCP_DB_ENGINE=postgresql
export MCP_DB_URL="postgresql://postgres:mypassword@localhost:5432/myapp"
npx mcp-database-server
### Option C: Config File (most flexible)```bash
# Copy the example
cp config.example.json config.json
# Edit it with your details
nano config.json
# Run it
MCP_DB_CONFIG=./config.json npx mcp-database-server
🖥️ Setup with Claude Desktop
Claude Desktop uses a config file at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Open that file and add:```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "postgresql",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "5432",
"MCP_DB_DATABASE": "myapp",
"MCP_DB_USER": "postgres",
"MCP_DB_PASSWORD": "secret"
}
}
}
}
**Save the file, restart Claude Desktop.** That's it.
Now you can open Claude and say:
> *"Show me all tables in my database"*
---
## 💻 Setup with Claude Code```bash
# Simple: one database
claude mcp add database -- npx -y mcp-database-server
# With config file
claude mcp add database -- env MCP_DB_CONFIG=./config.json npx -y mcp-database-server
📁 Setup with Config File
Create a file called config.json:```json
{
"server": {
"name": "my-databases",
"logLevel": "info"
},
"connections": [
{
"id": "my-postgres",
"engine": "postgresql",
"host": "localhost",
"port": 5432,
"database": "myapp",
"username": "postgres",
"password": "secret",
"readOnly": true
}
],
"security": {
"sqlInjectionProtection": true,
"allowDDL": false,
"allowDML": true,
"rateLimitPerMinute": 120,
"auditLogging": true
}
}
### Multiple databases in one config:```json
{
"connections": [
{
"id": "app-db",
"engine": "postgresql",
"connectionString": "postgresql://user:pass@host:5432/myapp",
"readOnly": true
},
{
"id": "cache",
"engine": "redis",
"host": "localhost",
"port": 6379
},
{
"id": "analytics",
"engine": "clickhouse",
"host": "localhost",
"port": 8123,
"database": "analytics",
"readOnly": true
}
],
"security": {
"allowDDL": false,
"rateLimitPerMinute": 60
}
}
🛠 All MCP Tools Reference
Once the server is running, these tools are available to the LLM:
list_supported_databases
Lists all 22 database engines with categories and aliases.
Example prompt to Claude:
> "What databases can you connect to?"
connect
Opens a new connection to a database.
Parameters:
| Parameter | Required | Description |
|---|---|---|
connection_id |
✅ | A name you pick, e.g. "my-postgres" |
engine |
✅ | Database type, e.g. "postgresql" |
connection_string |
Full URI, e.g. "postgresql://user:pass@host:5432/db" |
|
host |
Hostname or IP | |
port |
Port number | |
database |
Database name | |
username |
Username | |
password |
Password | |
ssl |
true to enable SSL |
|
read_only |
true to block all writes |
|
region |
AWS region (DynamoDB only) | |
project_id |
GCP project ID (Firestore only) |
Example prompt to Claude:
> "Connect to my PostgreSQL database at localhost, port 5432, database called myapp, user postgres, password secret"
disconnect
Closes a connection.
Example prompt:
> "Disconnect from my-postgres"
list_connections
Shows all open connections and their health status (🟢 or 🔴).
Example prompt:
> "Show me all active database connections"
query
Executes a query. This is the main tool. Works differently for each database type — see the database-specific guides below.
Parameters:
| Parameter | Required | Description |
|---|---|---|
connection_id |
✅ | Which connection to query |
sql |
✅ | The query (SQL, Cypher, JSON, or Flux) |
params |
Array of parameter values for safe queries |
Example prompt:
> "Run this query on my-postgres: SELECT name, email FROM users WHERE created_at > '2024-01-01'"
list_tables
Lists all tables, collections, indexes, or key patterns.
Example prompt:
> "What tables are in my-postgres?"
describe_table
Shows the full schema of a table: column names, types, primary keys, foreign keys, indexes.
Example prompt:
> "Describe the users table in my-postgres"
list_schemas
Lists available schemas, databases, or keyspaces.
Example prompt:
> "What schemas are available in my-postgres?"
ping
Health check — tells you if a connection is alive.
Example prompt:
> "Is my-postgres still connected?"
get_server_info
Gets the database version info.
Example prompt:
> "What version of PostgreSQL is my-postgres running?"
get_audit_log
Shows recent query history for security review.
Example prompt:
> "Show me the last 20 queries that were run"
get_security_config
Displays the current security policy settings.
Example prompt:
> "What security settings are active?"
📘 Database Guides
Each guide below shows you exactly how to set up and use each database, with copy-paste examples.
🐘 PostgreSQL
What it is: The world's most popular open-source relational database.
Install the driver```bash
npm install -g pg
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "postgresql",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "5432",
"MCP_DB_DATABASE": "myapp",
"MCP_DB_USER": "postgres",
"MCP_DB_PASSWORD": "secret",
"MCP_DB_READ_ONLY": "true",
"MCP_DB_SSL": "false"
}
}
}
}
Using a connection string instead```json
{
"env": {
"MCP_DB_ENGINE": "postgresql",
"MCP_DB_URL": "postgresql://postgres:secret@localhost:5432/myapp?sslmode=require"
}
}
### Config file version```json
{
"connections": [{
"id": "my-postgres",
"engine": "postgresql",
"host": "localhost",
"port": 5432,
"database": "myapp",
"username": "postgres",
"password": "secret",
"readOnly": true,
"ssl": { "enabled": false },
"pool": { "min": 1, "max": 10 },
"queryTimeout": 30000,
"maxRows": 1000
}]
}
Query examples
Simple SELECT:```sql
SELECT * FROM users WHERE active = true ORDER BY created_at DESC LIMIT 10
**With parameters (safe — prevents SQL injection):**```
sql: "SELECT * FROM users WHERE age > $1 AND city = $2"
params: [25, "London"]
JOINs:```sql
SELECT u.name, o.total, o.created_at
FROM users u
JOIN orders o ON o.user_id = u.id
WHERE o.total > 100
ORDER BY o.created_at DESC
LIMIT 20
**Aggregation:**```sql
SELECT
DATE_TRUNC('month', created_at) AS month,
COUNT(*) AS signups,
AVG(age) AS avg_age
FROM users
GROUP BY month
ORDER BY month DESC
INSERT (only works if readOnly is false):```
sql: "INSERT INTO users (name, email, age) VALUES ($1, $2, $3)"
params: ["Alice", "alice@example.com", 30]
**UPDATE:**```
sql: "UPDATE users SET active = false WHERE last_login < $1"
params: ["2024-01-01"]
Example prompts to Claude
> "Show me all users who signed up this month"
>
> "What are the top 10 products by revenue?"
>
> "Find all orders that haven't been shipped yet"
>
> "How many users signed up each week for the last 3 months?"
>
> "Show me the schema of the orders table"
🐬 MySQL
What it is: The world's most popular open-source relational database (used by Facebook, Twitter, YouTube).
Install the driver```bash
npm install -g mysql2
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "mysql",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "3306",
"MCP_DB_DATABASE": "myapp",
"MCP_DB_USER": "root",
"MCP_DB_PASSWORD": "secret",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
Connection string version```json
{
"env": {
"MCP_DB_ENGINE": "mysql",
"MCP_DB_URL": "mysql://root:secret@localhost:3306/myapp"
}
}
### Query examples
**Simple SELECT:**```sql
SELECT * FROM products WHERE price > 50 ORDER BY price DESC LIMIT 10
With parameters (use ? placeholders):```
sql: "SELECT * FROM users WHERE country = ? AND age >= ?"
params: ["India", 18]
**GROUP BY:**```sql
SELECT category, COUNT(*) AS product_count, AVG(price) AS avg_price
FROM products
GROUP BY category
ORDER BY product_count DESC
Example prompts to Claude
> "What are the most expensive products in each category?"
>
> "Show me all customers who haven't ordered in 6 months"
>
> "Count how many orders we got per day this week"
🦭 MariaDB
What it is: A drop-in replacement for MySQL, created by MySQL's original developers. Uses the exact same driver and syntax as MySQL.
Install the driver```bash
npm install -g mysql2
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "mariadb",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "3306",
"MCP_DB_DATABASE": "myapp",
"MCP_DB_USER": "root",
"MCP_DB_PASSWORD": "secret"
}
}
}
}
Query examples
Same as MySQL! Use ? for parameters:```
sql: "SELECT * FROM orders WHERE status = ? AND total > ?"
params: ["pending", 100]
---
## 📁 SQLite
**What it is:** A file-based database. No server needed. Perfect for local apps, prototyping, or embedded databases.
### Install the driver```bash
npm install -g better-sqlite3
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "sqlite",
"MCP_DB_DATABASE": "/path/to/your/database.db",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
### Using in-memory SQLite (for testing)```json
{
"env": {
"MCP_DB_ENGINE": "sqlite",
"MCP_DB_DATABASE": ":memory:"
}
}
Query examples
Standard SQL works:```sql
SELECT * FROM todos WHERE completed = 0 ORDER BY created_at DESC
**With parameters (use positional `?`):**```
sql: "SELECT * FROM notes WHERE tag = ? AND archived = ?"
params: ["work", 0]
Check table info:```sql
PRAGMA table_info('users')
### Example prompts to Claude
> *"Open my local database at /Users/me/app/data.db and show me all tables"*
>
> *"How many records are in the notes table?"*
---
## 🏢 Microsoft SQL Server (MSSQL)
**What it is:** Microsoft's enterprise relational database.
### Install the driver```bash
npm install -g tedious
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "mssql",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "1433",
"MCP_DB_DATABASE": "MyDatabase",
"MCP_DB_USER": "sa",
"MCP_DB_PASSWORD": "YourStrong!Passw0rd",
"MCP_DB_SSL": "true"
}
}
}
}
### Query examples
**Note:** MSSQL uses `@p0`, `@p1`, `@p2` for parameter placeholders.```
sql: "SELECT TOP 10 * FROM Employees WHERE Department = @p0 AND Salary > @p1"
params: ["Engineering", 80000]
Pagination with OFFSET/FETCH:```sql
SELECT * FROM Products
ORDER BY ProductName
OFFSET 20 ROWS
FETCH NEXT 10 ROWS ONLY
### Example prompts to Claude
> *"Show me all employees in the Engineering department"*
>
> *"What's the average salary by department?"*
---
## 🔮 Oracle
**What it is:** Oracle's enterprise relational database. Used by banks, governments, and Fortune 500 companies.
### Install the driver```bash
npm install -g oracledb
> Note: Oracle Instant Client must also be installed on your system. See Oracle's install guide.
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "oracle",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "1521",
"MCP_DB_DATABASE": "ORCL",
"MCP_DB_USER": "hr",
"MCP_DB_PASSWORD": "secret"
}
}
}
}
### Query examples
**Note:** Oracle uses `:1`, `:2`, `:3` for parameter placeholders.```
sql: "SELECT * FROM employees WHERE department_id = :1 AND salary > :2"
params: [60, 5000]
🪳 CockroachDB
What it is: A distributed SQL database built for global scale. Wire-compatible with PostgreSQL.
Install the driver```bash
npm install -g pg
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "cockroachdb",
"MCP_DB_URL": "postgresql://user:pass@localhost:26257/defaultdb?sslmode=verify-full",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
Query examples
Uses standard PostgreSQL syntax. Same $1, $2 parameters:```
sql: "SELECT * FROM accounts WHERE balance > $1"
params: [1000]
---
## ⚡ Neon (Serverless Postgres)
**What it is:** Serverless PostgreSQL. Scales to zero. Pay per query.
### Install the driver```bash
npm install -g pg
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "neon",
"MCP_DB_URL": "postgresql://user:pass@ep-cool-name-123456.us-east-2.aws.neon.tech/neondb?sslmode=require",
"MCP_DB_SSL": "true",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
> **Where to find your connection string:** Neon Console → Your Project → Connection Details → Copy the connection string.
### Query examples
Standard PostgreSQL syntax. Same as PostgreSQL above.
---
## 🟢 Supabase
**What it is:** An open-source Firebase alternative built on PostgreSQL.
### Install the driver```bash
npm install -g pg
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "supabase",
"MCP_DB_URL": "postgresql://postgres.xxxxxxxxxxxx:YOUR-PASSWORD@aws-0-us-east-1.pooler.supabase.com:6543/postgres",
"MCP_DB_SSL": "true",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
> **Where to find your connection string:** Supabase Dashboard → Settings → Database → Connection string → URI.
### Query examples
Standard PostgreSQL syntax. Same as PostgreSQL above.
---
## 🪐 PlanetScale
**What it is:** Serverless MySQL platform by Vitess.
### Install the driver```bash
npm install -g mysql2
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "planetscale",
"MCP_DB_HOST": "aws.connect.psdb.cloud",
"MCP_DB_USER": "xxxxxxxxxx",
"MCP_DB_PASSWORD": "pscale_pw_xxxxxxxx",
"MCP_DB_DATABASE": "mydb",
"MCP_DB_SSL": "true",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
### Query examples
Standard MySQL syntax. Use `?` for parameters:```
sql: "SELECT * FROM orders WHERE status = ?"
params: ["shipped"]
⚡ TiDB
What it is: An open-source, distributed SQL database compatible with MySQL.
Install the driver```bash
npm install -g mysql2
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "tidb",
"MCP_DB_HOST": "gateway01.us-east-1.prod.aws.tidbcloud.com",
"MCP_DB_PORT": "4000",
"MCP_DB_DATABASE": "mydb",
"MCP_DB_USER": "root",
"MCP_DB_PASSWORD": "secret",
"MCP_DB_SSL": "true"
}
}
}
}
Query examples
Standard MySQL syntax. Same as MySQL above.
⚡ SingleStore
What it is: A distributed SQL database designed for real-time analytics. MySQL-compatible.
Install the driver```bash
npm install -g mysql2
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "singlestore",
"MCP_DB_HOST": "svc-xxxxxxxxxx.svc.singlestore.com",
"MCP_DB_PORT": "3306",
"MCP_DB_DATABASE": "mydb",
"MCP_DB_USER": "admin",
"MCP_DB_PASSWORD": "secret",
"MCP_DB_SSL": "true"
}
}
}
}
🍃 MongoDB
What it is: The most popular document database. Stores data as flexible JSON-like documents instead of rows and columns.
Install the driver```bash
npm install -g mongodb
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "mongodb",
"MCP_DB_URL": "mongodb://localhost:27017/myapp",
"MCP_DB_DATABASE": "myapp",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
MongoDB Atlas (cloud)```json
{
"env": {
"MCP_DB_ENGINE": "mongodb",
"MCP_DB_URL": "mongodb+srv://user:pass@cluster0.xxxxx.mongodb.net/myapp?retryWrites=true&w=majority",
"MCP_DB_DATABASE": "myapp"
}
}
### How MongoDB queries work
MongoDB does NOT use SQL. Instead, you pass a **JSON command**. Here's the format:```json
{
"collection": "name_of_collection",
"operation": "find|findOne|aggregate|insertOne|...",
"filter": {},
"projection": {},
"sort": {},
"limit": 100
}
Query examples
Find all documents in a collection:```json
{
"collection": "users",
"operation": "find",
"filter": {},
"limit": 50
}
**Find with filters:**```json
{
"collection": "users",
"operation": "find",
"filter": { "age": { "$gt": 25 }, "city": "Mumbai" },
"projection": { "name": 1, "email": 1 },
"sort": { "name": 1 },
"limit": 20
}
Find one document:```json
{
"collection": "users",
"operation": "findOne",
"filter": { "email": "alice@example.com" }
}
**Count documents:**```json
{
"collection": "orders",
"operation": "countDocuments",
"filter": { "status": "pending" }
}
Aggregation pipeline:```json
{
"collection": "orders",
"operation": "aggregate",
"pipeline": [
{ "$match": { "status": "completed" } },
{ "$group": { "_id": "$product", "total": { "$sum": "$amount" } } },
{ "$sort": { "total": -1 } },
{ "$limit": 10 }
]
}
**Get distinct values:**```json
{
"collection": "users",
"operation": "distinct",
"field": "country"
}
Insert one document (only if readOnly is false):```json
{
"collection": "users",
"operation": "insertOne",
"document": { "name": "Alice", "email": "alice@example.com", "age": 30 }
}
**Insert many documents:**```json
{
"collection": "products",
"operation": "insertMany",
"documents": [
{ "name": "Widget A", "price": 9.99 },
{ "name": "Widget B", "price": 19.99 }
]
}
Update one document:```json
{
"collection": "users",
"operation": "updateOne",
"filter": { "email": "alice@example.com" },
"update": { "$set": { "age": 31, "updatedAt": "2024-06-01" } }
}
**Update many documents:**```json
{
"collection": "users",
"operation": "updateMany",
"filter": { "active": false },
"update": { "$set": { "archived": true } }
}
Delete one document:```json
{
"collection": "users",
"operation": "deleteOne",
"filter": { "email": "bob@example.com" }
}
**Delete many documents:**```json
{
"collection": "logs",
"operation": "deleteMany",
"filter": { "createdAt": { "$lt": "2024-01-01" } }
}
Example prompts to Claude
> "Show me all users from India who are over 25"
>
> "What are the top 10 products by total sales?"
>
> "Count how many pending orders we have"
>
> "List all unique countries in our user database"
🔴 Redis
What it is: An in-memory key-value store. Blazing fast. Used for caching, sessions, queues, and real-time data.
Install the driver```bash
npm install -g redis
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "redis",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "6379"
}
}
}
}
With password and SSL (e.g., Redis Cloud)```json
{
"env": {
"MCP_DB_ENGINE": "redis",
"MCP_DB_URL": "rediss://default:your_password@redis-12345.c1.us-east-1-2.ec2.redns.redis-cloud.com:12345",
"MCP_DB_SSL": "true"
}
}
### How Redis queries work
Redis uses **commands**, not SQL. You can type them as plain text or JSON.
### Query examples (plain text)
**Get a value:**```
GET user:1001
Set a value:```
SET user:1001 "Alice"
**Set with expiry (60 seconds):**```
SET session:abc123 "token_data" EX 60
Get a hash (like an object):```
HGETALL user:1001
**Set hash fields:**```
HSET user:1001 name "Alice" age "30" city "Mumbai"
List all keys matching a pattern:```
KEYS user:*
**Delete a key:**```
DEL user:1001
Get list items:```
LRANGE myqueue 0 -1
**Increment a counter:**```
INCR page:views:homepage
Check key type:```
TYPE user:1001
**Get TTL (time to live):**```
TTL session:abc123
Query examples (JSON format)```json
{ "command": "HGETALL", "args": ["user:1001"] }
{ "command": "SET", "args": ["greeting", "hello world"] }
```
### Example prompts to Claude
> *"What's stored in the key user:1001?"*
>
> *"Show me all session keys"*
>
> *"How many page views does the homepage have?"*
---
## 📊 Cassandra / ScyllaDB
**What it is:** A wide-column distributed database designed for massive scale. Used by Apple, Netflix, Discord.
### Install the driver```bash
npm install -g cassandra-driver
```
### Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "cassandra",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "9042",
"MCP_DB_DATABASE": "my_keyspace",
"MCP_DB_USER": "cassandra",
"MCP_DB_PASSWORD": "cassandra"
}
}
}
}
```
### Config file with datacenter```json
{
"connections": [{
"id": "my-cassandra",
"engine": "cassandra",
"host": "node1.example.com,node2.example.com",
"port": 9042,
"database": "my_keyspace",
"username": "admin",
"password": "secret",
"options": { "datacenter": "us-east-1" }
}]
}
```
### Query examples
Cassandra uses CQL (Cassandra Query Language), which looks like SQL:```
sql: "SELECT * FROM users WHERE user_id = ? LIMIT 10"
params: ["user-abc-123"]
sql: "SELECT * FROM events WHERE partition_key = ? AND event_time > ? ALLOW FILTERING"
params: ["sensor-01", "2024-06-01T00:00:00Z"]
> ⚠️ **Important:** Cassandra requires you to query by partition key. You can't do arbitrary WHERE clauses like in PostgreSQL.
---
## ⚡ ClickHouse
**What it is:** A column-oriented database for blazing-fast analytics. Can process billions of rows per second.
### Install the driver```bash
npm install -g @clickhouse/client
Claude Desktop config```json
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "mcp-database-server"],
"env": {
"MCP_DB_ENGINE": "clickhouse",
"MCP_DB_HOST": "localhost",
"MCP_DB_PORT": "8123",
"MCP_DB_DATABASE": "analytics",
"MCP_DB_USER": "default",
"MCP_DB_PASSWORD": "",
"MCP_DB_READ_ONLY": "true"
}
}
}
}
### ClickHouse Cloud```json
{
"env": {
"MCP_DB_ENGINE": "clickhouse",
"MCP_DB_URL": "https://xxxx.clickhouse.cloud:8443",
"MCP_DB_USER": "default",
"MCP_DB_PASSWORD": "your-password",
"MCP_DB_DATABASE": "default",
"MCP_DB_SSL": "true"
}
}
Query examples
Standard SQL works, with ClickHouse-specific functions:sql
SELECT
toDate(timestamp) AS day,
count() AS events,
uniq(user_id) AS unique_users
FROM events
WHERE timestamp >= now() - INTERVAL 7 DAY
GROUP BY day
ORDER BY day DESC
``````sql
SELECT
country,
count() AS users,
avg(session_duration) AS avg_duration
FROM user_sessions
GROUP BY country
ORDER BY users DESC
LIMIT 20
Example prompts to Claude
> "How many events did we get per day this week?"
>
> "What countries have the most active users?"
>
…(正文过长,页面只展示前面部分,完整内容见仓库)
