Read-only by default · opt in to writes

Stop making your AI agent guess your schema.

sql-mcp gives Claude, Cursor, and any MCP client live, accurate access to your MySQL, PostgreSQL, SQL Server, or SQLite database — real tables, real types, real rows, straight from the source.

$ npx @salmanulfaris/sql-mcp --db … Add to your client
claude — sql-mcp (postgres)
> which users signed up but never placed an order? ⏺ sql-mcp:list_tables users · orders · order_items · products · payments ⏺ sql-mcp:describe_table (users) id int PK · email varchar · created_at timestamptz ⏺ sql-mcp:query SELECT u.email, u.created_at FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE o.id IS NULL; → 3 rows · read-only, no --allow-write needed # No schema pasted. No guessing. Just the live database.
install

Add it to your client in one line

Enter your database details, pick your client, and copy the generated command. It all runs in your browser — nothing you type is sent anywhere.

terminal

        

# Prefer a .sql-mcp file or an env var to keep credentials out of your shell history.

one server, four engines

Point it at any SQL database

The driver is auto-detected from the connection URI. Same tools, same permission model, whichever engine you run.

MySQL mysql://user:pass@host:3306/db mysql://
PostgreSQL postgres://user:pass@host:5432/db postgres:// · postgresql://
SQL Server mssql://user:pass@host:1433/db mssql:// · sqlserver://
SQLite sqlite:./path/to/file.db sqlite: · file: · *.db

Three ways to hand it a database

Give sql-mcp a connection URI however suits your setup — a per-project file, a flag, or an environment variable.

  • .sql-mcp A file in your project root. Each project connects to its own database automatically, with nothing to change in your client. highest priority
  • --db Pass the connection URI on the command line. Handy for a quick run or straight inside your MCP client's config. then
  • DB_URL Set it in your shell or your client's env block. Keeps credentials out of config files and shell history. fallback

Set more than one and the highest wins — so a project's .sql-mcp always overrides a global --db or DB_URL.

six tools

Everything an agent needs to read a database

From a full schema dump to execution-plan analysis. Each tool declares exactly what it's allowed to do.

list_tables List every table and view in the database. read-only
describe_table Full schema for one table — columns, types, indexes, and foreign keys. read-only
get_schema Dump the whole database schema in a single call. read-only
get_sample_data Pull a handful of real rows to see the shape of the data. read-only
query Run SQL. The permission gate classifies each statement before it executes. gated
analyze_query Show the execution plan and flag full scans, missing indexes, and filesorts. plan-only
security model

Locked down until you say otherwise

Reads are always open. Everything that changes data stays closed behind an explicit flag — and a few things can never be opened at all.

● SELECT · SHOW · DESCRIBE · EXPLAIN Allowed out of the box — no flag required.
○ INSERT · UPDATE --allow-write Off until you opt in.
○ DELETE --allow-delete Its own separate gate, so reads and writes don't drag deletes along.
○ ALTER · CREATE · DROP · TRUNCATE --allow-ddl Schema changes stay behind their own flag.
○ DROP DATABASE --allow-drop-database Needs its own flag even when DDL is already enabled.
✕ Multi-statement queries Always blocked — SELECT 1; DROP TABLE x never runs.
✕ GRANT · REVOKE · CALL · LOAD DATA Unknown statement types are refused, not guessed at.