SafeSQL-MCP

A text-to-SQL MCP server an AI agent can't break.

Every query is parsed into a syntax tree, checked against allowlists, cost-checked with EXPLAIN and run read-only. Type any SQL below, or fire one of the attacks from the CI suite, and see which layer stops it.

Ctrl + Enter

Connect your own agent

This page is a front end to the same MCP server. Point Claude Code, Claude Desktop or Cursor at it and the model you already use does the asking; every query still goes through the guard.

How it works

1 · Static guard

Parses with sqlglot and decides on the tree: one statement, SELECT only, no write or lock node anywhere, every function and table on an allowlist.

2 · Rewrite

Injects a row limit and runs SQL regenerated from the checked tree, comments stripped and re-parsed. Text the guard never saw can't run.

3 · Runtime limits

Read-only transaction, statement timeout, an EXPLAIN cost cap before execution, and prepared statements that refuse stacked queries.

4 · Database role

A role with SELECT grants only, read-only by default, dangerous functions revoked. It holds even if every layer above failed.