# universal-db-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/Fashad-Ahmed/universal-mcp  
**GitHub Stars:** 1  
**Views:** 19  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/universal-db-mcp

## Description
Security-first MCP server for PostgreSQL, SQLite, MySQL, DuckDB with SQL injection prevention.

## Tools
Capabilities this server exposes over MCP:

- **query** — Execute a SQL query against the database.

Supports parameterized queries for injection safety. In read-only mode, destructive
operations (INSERT, UPDATE, DELETE, DROP, etc.) are blocked.
- **schema** — Get database schema information: tables, columns, types, and constraints.
- **explain** — Get query execution plan without running the query.
- **health** — Check database connection health and get server version info.
- **query_history** — Get recent query execution history (most recent first).
- **snapshot_schema** — Take a snapshot of the current database schema for later drift detection.
- **schema_diff** — Compare the current schema against the last snapshot taken with snapshot_schema.
- **list_databases** — List all configured databases and their connection status.

Returns:
    JSON with list of databases including key, type, database name, and connection status.

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

```json
"mcpServers": {
  "universal-db-mcp": {
    "command": "uvx",
    "args": ["universal-db-mcp"],
    "env": {
      "POSTGRES_URI": "",
      "SQLITE_PATH": "",
      "MYSQL_URI": "",
      "DUCKDB_PATH": "",
      "ALLOW_DESTRUCTIVE": "",
      "MAX_RESULT_ROWS": "",
      "QUERY_TIMEOUT": "",
      "RATE_LIMIT_RPM": ""
    }
  }
}
```

**Requires environment variables:** `POSTGRES_URI`, `SQLITE_PATH`, `MYSQL_URI`, `DUCKDB_PATH`, `ALLOW_DESTRUCTIVE`, `MAX_RESULT_ROWS`, `QUERY_TIMEOUT`, `RATE_LIMIT_RPM` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What universal-db-mcp MCP server does

The universal-db-mcp MCP server gives AI agents database access through MCP tools for four supported systems: PostgreSQL, SQLite, MySQL, and DuckDB. SQLite and DuckDB can run locally without a separate database service. DuckDB can also be used for in-process analytics involving supported local data files.

The default operating mode is read-only. The server is designed for cases where an agent needs to inspect data or structure without receiving unrestricted SQL access. Destructive operations can be configured, but the README recommends using dedicated read-only database accounts and does not treat application-level controls as a replacement for database permissions.

## How it works

The server is implemented in Python with FastMCP and selects database adapters from environment configuration. A single process can be configured with more than one database connection. Agents can first call `schema` to inspect tables and columns, then use `query` for SQL generated from that structure.

Before a query reaches the database driver, the server applies eight protection layers. These include driver-level read-only settings, blocked write keywords, detection of common injection patterns, rejection of multiple statements, parameter type validation, result-size limits, identifier sanitization, and DuckDB-specific filesystem restrictions. The query tool limits results to `MAX_RESULT_ROWS`, which defaults to 1,000. The security model blocks patterns such as `UNION SELECT`, SQL comments, stacked statements, and several time-delay functions.

The `explain` tool returns a query execution plan without running the query. A `DRYRUN` setting can also be used while prototyping so the agent receives planning information instead of executing the statement. This is useful for reviewing generated SQL before allowing database work.

## Setup and configuration

Run the universal-db-mcp MCP server with `uvx universal-db-mcp`, or build and run the supplied Docker image. Set one or more connection variables before starting it: `POSTGRES_URI`, `SQLITE_PATH`, `MYSQL_URI`, or `DUCKDB_PATH`. DuckDB accepts `:memory:` for a temporary in-memory database. SQLite and DuckDB do not require a database server or Docker.

Each adapter has a read-only setting enabled by default: `POSTGRES_READONLY`, `SQLITE_READONLY`, `MYSQL_READONLY`, and `DUCKDB_READONLY`. Other controls include `ALLOW_DESTRUCTIVE`, `MAX_RESULT_ROWS`, `QUERY_TIMEOUT`, `RATE_LIMIT_RPM`, and `ENABLE_LOGGING`. MCP client configuration passes these values through the process environment. The README provides examples for Claude Desktop, Claude Code, Cursor, Windsurf, and Docker.

## Tools and capabilities

- `query`: Execute SQL subject to the configured security checks.
- `schema`: List tables and columns without additional configuration.
- `explain`: Retrieve a query plan without executing the query.
- `health`: Report connection status, database version, and pool metrics.
- `list_databases`: Show configured databases and their connection state.
- `query_history`: Inspect the last 100 executed queries.
- `snapshot_schema`: Save the current schema for later comparison.
- `schema_diff`: Compare the current schema with the most recent snapshot.

These tools support data exploration, generated-SQL review, connection diagnostics, and basic schema drift checks.

## Limitations and notes

The security filters are defense-in-depth controls, not a substitute for database permissions. Use credentials that cannot modify production data when possible. DuckDB has an adapter-level blocklist for filesystem and extension operations including `read_csv()`, `read_parquet()`, `glob()`, `LOAD`, `INSTALL`, `httpfs`, and `COPY`; read-only mode alone does not block every file read. Large query results are truncated at the configured row limit, and query history covers only the last 100 queries.

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

