# wenb1n-dev/SmartDB_MCP [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/wenb1n-dev/SmartDB_MCP  
**GitHub Stars:** 78  
**Views:** 6  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/wenb1n-dev-smartdb-mcp

## Description
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optimization, and more. Compatible with mainstream databases including MySQL, PostgreSQL, SQL Server, MariaDB, Dameng, and Oracle. Supports Streamable HTTP, SSE, and STDIO; integrates OAuth 2.0; and is designed for easy customization and extension by developers.

## Tools
Capabilities this server exposes over MCP:

- **execute_sql** — SQL execution tool that can execute ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE", "CREATE", "ALTER", "DROP", "TRUNCATE"] commands based on permission configuration
- **get_db_health** — Analyzes database health status (connection status, transaction status, running status, lock detection) and outputs professional diagnostic reports and solutions
- **get_table_desc** — Searches for table structures in the database based on table names, supports multi-table queries
- **get_table_index** — Searches for table indexes in the database based on table names, supports multi-table queries
- **get_table_name** — Database table name query tool. Used to query all table names in the database or search for corresponding table names based on Chinese table names or table descriptions
- **get_db_version** — Database version query tool
- **sql_creator** — SQL query generation tool that generates corresponding SQL query statements based on different database types
- **sql_optimize** — A professional SQL performance optimization tool that provides expert optimization suggestions based on execution plans, table structure information, table data volume, and table indexes.
- **execute_command** — Execute Redis commands (GET/SET/HGET/LPUSH etc.) with permission enforcement
- **get_key_info** — Query Redis key details (type, size, TTL, memory usage)
- **scan_keys** — Scan Redis keys by pattern using SCAN command (non-blocking)
- **execute_mongo_query** — Execute MongoDB queries (find/aggregate) with filter, projection, sort, pagination
- **execute_mongo_write** — Execute MongoDB writes (insert_one/insert_many/update_one/update_many/replace_one/delete_one/delete_many) with permission enforcement; supports Extended JSON ($oid/$date); update_many/delete_many require an explicit filter
- **get_collection_schema** — Infer collection schema by sampling documents (field names, types, presence)
- **get_collection_names** — List collections in a MongoDB database, with optional name pattern filter
- **get_collection_indexes** — Query index information for a MongoDB collection or all collections
- **mongo_explain** — Analyze MongoDB query execution plan (explain), including query planner and execution stats
- **execute_vector_search** — Execute vector similarity search on a collection, returning top-K nearest neighbors
- **get_collection_info** — Query vector collection metadata (dimension, metric type, schema, entity count)
- **get_vector_index_info** — Query vector index information (index type, parameters, build progress)
- **execute_es_query** — Execute Elasticsearch DSL queries (search/count/aggregate) with full DSL support
- **get_index_mapping** — Query index mappings (field types, analyzers) and settings
- **get_index_names** — List Elasticsearch indices
- **list_topics** — List Kafka topics
- **get_topic_info** — Query topic details: partitions, leader, replicas, offsets
- **get_consumer_lag** — Query consumer group lag

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "smartdb-mcp": {
    "command": "uvx",
    "args": ["SmartDB-MCP"],
    "env": {
      "DATABASE_CONFIG_FILE": "",
      "SERVER_HOST": "",
      "SERVER_PORT": "",
      "CLIENT_ID": "",
      "CLIENT_SECRET": "",
      "ACCESS_TOKEN_EXPIRE_MINUTES": "",
      "REFRESH_TOKEN_EXPIRE_DAYS": "",
      "TOKEN_SECRET_KEY": ""
    }
  }
}
```

**Requires environment variables:** `DATABASE_CONFIG_FILE`, `SERVER_HOST`, `SERVER_PORT`, `CLIENT_ID`, `CLIENT_SECRET`, `ACCESS_TOKEN_EXPIRE_MINUTES`, `REFRESH_TOKEN_EXPIRE_DAYS`, `TOKEN_SECRET_KEY` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What wenb1n-dev/SmartDB_MCP does

wenb1n-dev/SmartDB_MCP provides a single MCP interface for ten data sources across six categories: relational databases, Redis, MongoDB, Milvus, Elasticsearch, and Apache Kafka. The relational adapters cover MySQL, PostgreSQL, Oracle, SQL Server, and Dameng; the MySQL support also covers MariaDB according to the project description.

It combines operational access with inspection and maintenance tools. Depending on the configured connection pool, an MCP client can execute permitted SQL, inspect tables and indexes, query Redis keys, run MongoDB operations, search Milvus vectors, issue Elasticsearch DSL requests, or inspect Kafka topics and consumer lag.

## How it works

The gateway reads database connection pools from a JSON configuration file. Each pool identifies a data source and can include connection details, a role, and pool settings. Tool exposure is selected by the paradigm associated with each pool, so a relational connection receives relational tools while a Redis, MongoDB, Milvus, Elasticsearch, or Kafka connection receives the relevant set.

The server supports three MCP transport modes: STDIO, SSE, and Streamable HTTP. OAuth 2.0 settings provide client credentials, token lifetimes, a token encryption key, and an OAuth username and password. SQL and MongoDB write operations use permission enforcement; the SQL tool supports commands ranging from SELECT and EXPLAIN to INSERT, UPDATE, CREATE, ALTER, DROP, and TRUNCATE according to configuration.

## Setup and configuration

Set the path to the database configuration JSON with `DATABASE_CONFIG_FILE`. Server binding is controlled with `SERVER_HOST` and `SERVER_PORT`. OAuth-related environment settings include `CLIENT_ID`, `CLIENT_SECRET`, `ACCESS_TOKEN_EXPIRE_MINUTES`, `REFRESH_TOKEN_EXPIRE_DAYS`, and `TOKEN_SECRET_KEY`; the OAuth username and password are configured with `OAUTH_USER_NAME` and `OAUTH_USER_PASSWORD`.

A connection entry can specify host, port, user, password, database, schema, role, pool size, overflow capacity, connection recycling, timeout, and data-source type. OAuth client and key changes also need to be reflected in the corresponding static configuration.

## Tools and capabilities

Relational tools provide table-name, table-description, index, and version lookups, SQL execution, SQL generation, database health analysis, and SQL optimization based on execution plans and database metadata. Health reports cover areas such as connections, transactions, running state, and locks.

Redis tools execute permitted commands, inspect key type, size, TTL, and memory usage, and scan keys by pattern with the non-blocking SCAN command.

MongoDB tools handle find and aggregate queries, writes, collection names, sampled schemas, indexes, and query plans. Extended JSON values such as `$oid` and `$date` are supported, and bulk updates or deletes require an explicit filter.

Milvus tools run vector similarity searches and inspect collection and vector-index metadata. Elasticsearch tools execute search, count, and aggregation requests, and inspect index names, mappings, and settings. Kafka tools list topics, report topic metadata, and measure consumer-group lag.

## Limitations and notes

Tool availability depends on the configured connection pool and its data paradigm. SQL and MongoDB write capabilities are subject to permission rules. The supported database versions include MySQL 5.6+, PostgreSQL 9.6+, Oracle 12+, SQL Server 2012+, Dameng 8.0+, Redis 5.0+, MongoDB 4.0+, and Milvus 2.3+; Elasticsearch and Kafka support depends on the stated Python driver versions and server compatibility.

_Full upstream README: https://allmcps.com/mcp/wenb1n-dev-smartdb-mcp/readme_

