SQL Safe MCP logo

SQL Safe MCP

Read-only MCP access to SQL Server, MySQL, and MariaDB metadata and validated queries with protected PII tokens.

Install SQL Safe MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "sql-safe-mcp": {
      "command": "uvx",
      "args": [
        "sql-safe-mcp"
      ],
      "env": {
        "SQL_SAFE_MCP_CONFIG": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Install not yet sandbox-tested— we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

SQL Safe MCP provides coding agents with read-only access to SQL Server, MySQL, and MariaDB schema information and selected data queries. It exposes seven tools for server and database discovery, table definitions, stored procedures, and restricted SELECT statements. Metadata access is available by default, while procedure access and row queries require higher access levels; protected columns are returned as authenticated tokens rather than plaintext. Use it when an agent needs database context without write tools or direct exposure of configured personal data.

Use cases

  • Inspect database schemas while writing application code
  • Trace tables, keys, and indexes without granting write access
  • Query approved rows while masking configured personal data
  • Review stored procedure definitions under a higher access level

Key features

  • Read-only SQL Server, MySQL, and MariaDB access
  • Schema, table, key, index, and procedure inspection
  • Validated SELECT queries only
  • Alias-bound tokens for configured PII columns
  • Multiple database aliases with isolated policies
  • Environment-based secret configuration

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 62d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 14d ago via OSV.dev · sql-safe-mcp (PyPI)

How SQL Safe MCP works

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.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about SQL Safe MCP

SQL Safe MCP is an MCP server that connects coding agents to SQL Server, MySQL, and MariaDB. Its main tools list database metadata, inspect tables and stored procedures, and run validated read-only SELECT queries. Configured PII columns are returned as authenticated tokens instead of plaintext.

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

Configure it with a YAML file referenced by `SQL_SAFE_MCP_CONFIG` or `--config`. Define named server aliases, engines, access levels, and environment-based connection URL placeholders, then run `sql-safe-mcp --check-config` to validate the file without connecting.

No, SQL Safe MCP exposes read-only tools and does not execute arbitrary agent-written SQL. Its query tool runs only a validated, regenerated SELECT statement, while database permissions should still use a least-privilege login.

Yes, the server can be configured for Claude Desktop and Claude Code over stdio. Provide `SQL_SAFE_MCP_CONFIG` and the environment variables referenced by the YAML configuration through the client host.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewSQL Safe MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/sql-safe-mcp?style=directory)](https://allmcps.com/mcp/sql-safe-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/sql-safe-mcp"><img src="https://allmcps.com/api/badge/sql-safe-mcp?style=directory" alt="SQL Safe MCP on AllMCPs" /></a>