sqlguard-mcp
Provides read-only access to SQLite databases, enabling agents to list databases and tables, describe schemas, search stored values, and run guarded SELECT queries without modifying data.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
sqlguard-mcp:只读 SQL 防护 MCP 服务器
A read-only SQLite MCP server for AI agents. It lets Claude Code, Claude Desktop or any MCP client explore and query SQLite databases, and it is built so that a model cannot change your data even when it tries to.
It was extracted from MetricLens, a text-to-SQL project evaluated on the BIRD Mini-Dev benchmark, where the same guard ran about 20,000 model-generated queries and a prompt-injection test.
Why another SQLite server
The common reference SQLite server exposes write tools. For an agent that only needs to answer questions about data, that is more power than it should have. A read-only file mode alone is not enough either: SQLite still lets a read-only connection run ATTACH, most PRAGMAs and CREATE TEMP TABLE.
sqlguard-mcp stacks five layers:
Static check: sqlglot must parse the input as a single
SELECT(CTEs andUNIONincluded). Multiple statements and write nodes anywhere in the tree, such asWITH t AS (...) DELETE ..., are rejected.Read-only connection: the database is opened with
mode=ro, and a missing path is an error rather than a new empty file.Authorizer:
sqlite3.set_authorizerallows read actions and a few metadata pragmas only, soATTACH,PRAGMA writable_schema = 1and temp tables are refused even if layer 1 is bypassed.Timeout: a progress handler interrupts queries that run too long.
Row cap: results are fetched with a hard limit so a large table cannot flood the model's context.
SQL that sqlglot cannot parse is still passed to SQLite, so the agent gets SQLite's own error message and can correct itself; layers 2 and 3 still apply.
Related MCP server: shop-mcp
Tools
Tool | Purpose |
| db_id of every database (the file name without extension) |
| tables and their column counts |
| columns, types, primary and foreign keys, 3 sample rows |
| case-insensitive search of text columns, to find the value actually stored (the user says "female", the column holds |
| runs one |
Usage
Run it straight from GitHub with uv:
uvx --from git+https://github.com/kennywu411-dev/sqlguard-mcp sqlguard-mcp path/to/shop.dbOr from a checkout, with more than one database and your own limits:
uv run sqlguard-mcp path/to/shop.db path/to/folder_of_dbs --timeout 30 --max-rows 1000Add it to Claude Code:
claude mcp add sqlguard -- uvx --from git+https://github.com/kennywu411-dev/sqlguard-mcp sqlguard-mcp /path/to/shop.dbInspect it with the MCP Inspector:
npx @modelcontextprotocol/inspector uv run sqlguard-mcp /path/to/shop.dbDevelopment
uv sync
uv run pytest
uv run ruff checkThe tests include write attempts that bypass the static check, to show the connection layers hold on their own, plus a row of injected instructions stored in the data to show it comes back as plain data.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to explore and query SQLite databases through read-only tools, with defense-in-depth sandboxing preventing any data modifications.MIT
- AlicenseAqualityCmaintenanceEnables AI agents to safely explore and query a SQLite database in read-only mode, allowing them to inspect schema and run analytical SQL queries without risking data modification.3MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to safely query and explore SQLite databases through read-only, guard-protected tools that block writes, sensitive table access, and runaway queries.1MIT
- AlicenseAqualityBmaintenanceEnables AI agents to inspect database schemas and run strictly read-only SQL queries with guardrails against destructive statements, multi-statement chaining, and unbounded scans. Supports SQLite natively and PostgreSQL optionally.437 PyPIMIT