# mahAnuj/mcp-multi-db [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/mahAnuj/mcp-multi-db  
**GitHub Stars:** 1  
**npm Downloads (last month):** 545  
**Views:** 8  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mahanuj-mcp-multi-db

## Description
One MCP server for PostgreSQL, MySQL, and SQLite. Unified read-only tools (listdatabases, listtables, describetable, runquery) across all three engines with two-layer read-only enforcement (SQL-text guard + DB-level read-only transactions). Install: npx -y mcp-multi-db.

## Tools
Capabilities this server exposes over MCP:

- **list_databases** — List all configured database connections (id, type, label, description, and policy when one is set: which tools are enabled, row cap, whether tables are restricted, which columns are redacted). Call this first to discover which database_id to use.
- **list_tables** — List tables and views in a configured database.
- **describe_table** — Describe columns for a table in a configured database.
- **run_query** — Execute a read-only SQL query (SELECT, WITH, EXPLAIN) on a configured database. Writes are blocked. If the database has a policy, queries reading tables outside it are refused with the reason, and redacted columns come back as "[redacted]" (listed in `redacted`).

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

```json
"mcpServers": {
  "mcp-multi-db": {
    "command": "npx",
    "args": ["-y","mcp-multi-db"],
    "env": {
      "MCP_DB_CONFIG": "",
      "MCP_DATABASES": ""
    }
  }
}
```

**Requires environment variables:** `MCP_DB_CONFIG`, `MCP_DATABASES` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What mahAnuj/mcp-multi-db does

mahAnuj/mcp-multi-db provides one MCP endpoint for multiple SQL database engines: PostgreSQL, MySQL, and SQLite. Each connection receives a unique ID, and the agent selects that ID when inspecting or querying a database. Human-readable labels and descriptions can help distinguish connections in the agent's context.

The server exposes four tools:

- `list_databases` returns configured connections and their effective row limits.
- `list_tables` lists tables and views for a selected database.
- `describe_table` returns column metadata for a table.
- `run_query` executes read-only SQL using `SELECT`, `WITH`, or `EXPLAIN` statements.

It fits database exploration, reporting, and read-only analytics workflows where the agent needs to work across different SQL backends through a consistent interface.

## How it works

The server communicates with MCP clients over standard input and output. An MCP client starts `npx -y mcp-multi-db` and passes the database configuration through the environment. The agent first identifies a connection, then can inspect its tables and columns before submitting a query.

Queries are protected by two checks: a SQL-text guard rejects unsupported write operations, and the database adapter uses read-only transaction behavior. Results are bounded by a default row count and a maximum row count. The server-wide maximum cannot exceed 10,000 rows, and adapters stop fetching when the applicable cap is reached.

Optional per-database policies can restrict exposed tools, allow or deny tables, redact columns, narrow row limits, apply query budgets, and record tool activity in JSONL audit logs. Table policies are evaluated from the database engine's query plan for PostgreSQL and SQLite, while column redaction uses result-column origin metadata so aliases do not bypass it.

## Setup and configuration

Install is not required for the normal launch path; `npx` downloads the package when needed. Create a JSON configuration containing a `databases` array. PostgreSQL and MySQL entries use a `connectionString`; SQLite entries use an absolute `path`. Every entry requires a unique `id` and a `type` of `postgres`, `mysql`, or `sqlite`.

Set `MCP_DB_CONFIG` to the configuration file path. `MCP_DATABASES` can instead hold the JSON inline. The file or inline value may be either an object containing `databases` or a bare array. Do not commit configuration files containing credentials, and prefer read-only database users.

A standard client registration uses:

```json
{
  "command": "npx",
  "args": ["-y", "mcp-multi-db"],
  "env": {
    "MCP_DB_CONFIG": "/absolute/path/to/databases.json"
  }
}
```

The server can also be installed globally with npm and launched as `mcp-multi-db`.

## Tools and capabilities

Schema discovery is built into the tool set, allowing an agent to identify available databases, enumerate tables or views, and inspect column metadata before composing SQL. `run_query` supports read-only analytical statements rather than mutations.

Configuration can set `limits.defaultRows` and `limits.maxRows` globally. A database policy may reduce those values, but cannot increase the server-wide limits. Governance options include a per-database tool list, table allowlists or denylists, column redaction, statement timeouts for PostgreSQL and MySQL, per-database query rate limits, and audit records that omit result values. Audit entries can store full SQL or a SHA-256 SQL hash.

## Limitations and notes

The server is read-only by design; it is not intended for INSERT, UPDATE, DELETE, schema changes, or other mutations. Table allow and deny policies are supported for PostgreSQL and SQLite. Statement timeouts are available for PostgreSQL and MySQL but not SQLite. The hard row ceiling is 10,000, regardless of configuration. SQLite connections use database file paths, while PostgreSQL and MySQL connections use standard connection URIs.

_Full upstream README: https://allmcps.com/mcp/mahanuj-mcp-multi-db/readme_

