# SQL Safe MCP [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/proprock/sql-safe-mcp  
**GitHub Stars:** 0  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/sql-safe-mcp

## Description
Minimal, read-only, PII-safe MCP server for SQL databases.

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

```json
"mcpServers": {
  "sql-safe-mcp": {
    "command": "uvx",
    "args": ["sql-safe-mcp"],
    "env": {
      "SQL_SAFE_MCP_CONFIG": ""
    }
  }
}
```

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

## Documentation

## What SQL Safe MCP does

SQL Safe MCP gives an MCP-compatible coding agent a controlled view of SQL Server, MySQL, or MariaDB databases. It can inspect configured server aliases, visible databases, tables, columns, keys, constraints, indexes, and stored procedures. The server is read-only by construction: agents cannot submit arbitrary SQL or use the exposed tools to change data.

A single process can serve multiple named database aliases. Each alias has its own connection, access level, and optional PII protection policy. Database operations must identify an explicit alias; the server does not discover databases across the network.

## How it works

Database metadata is collected through SQLAlchemy Inspector and fixed catalog queries. The `execute_sql` tool accepts only a validated and regenerated SELECT statement, and is available only for an alias configured with `all_pii_safe` and its own PII key. SQL Server queries use the platform’s syntax, while MySQL and MariaDB use `LIMIT` for row limiting.

PII protection applies to columns configured on an `all_pii_safe` alias. Returned values are alias-bound authenticated tokens with the `pii:v1:` prefix instead of plaintext. Agents can still project, count, and compare protected values with `=` or `IN` when they already have valid tokens. Tokens cannot be reused with another alias or key.

Validation fails closed. Unknown SQL syntax, unresolved column lineage, and unsupported protected-value types are rejected. Errors can identify candidate schemas for ambiguous names, but do not expose credentials, connection details, keys, tokens, or returned rows. Connection and timeout failures include a reference that can be matched with sanitized stderr diagnostics.

## Setup and configuration

Install with `uvx sql-safe-mcp` or `pip install sql-safe-mcp`. Python 3.12 through 3.14 is required. SQL Server connections additionally need Microsoft ODBC Driver 18; MySQL and MariaDB use the bundled PyMySQL driver.

Create a YAML configuration with a `version`, named `servers`, an `engine`, an `access_level`, and a connection URL. Keep the URL out of the YAML by using an environment placeholder such as `${REPORTING_SQL_URL}`. The `metadata` access level is the default and exposes navigation and table structure. `meta_and_code` adds stored procedure access, while `all_pii_safe` permits the protected query workflow when paired with a PII key and rules.

Set `SQL_SAFE_MCP_CONFIG` to the YAML path, or pass `--config`, then run `sql-safe-mcp --check-config` to validate configuration without connecting to a database. The server also validates configuration at startup. Supply all referenced environment variables through the MCP host rather than committing secrets to tracked files.

## Tools and capabilities

The seven read-only tools are:

- `list_servers` for configured aliases.
- `list_databases` for databases visible to the account.
- `list_tables` for base tables with schema or name filters.
- `get_table_definition` for one table’s columns, keys, constraints, and indexes.
- `list_stored_procedures` for procedure names without definitions.
- `get_stored_procedure` for one procedure definition.
- `execute_sql` for one restricted SELECT on an eligible protected alias.

Stored procedure listing and retrieval require `meta_and_code` or `all_pii_safe`. Use a least-privilege database login because database permissions remain the primary access control.

## Limitations and notes

The server supports SQL Server, MySQL, and MariaDB. For MySQL and MariaDB, `schema` is always `null` because the database serves as the catalog. All tools are annotated read-only, and the server never executes agent-authored SQL directly. PII token behavior depends on configured aliases, keys, and protection rules, so queries involving protected data must use valid tokens from the same security context.

_Full upstream README: https://allmcps.com/mcp/sql-safe-mcp/readme_

