Skip to content

Connecting AI agents to databases with MCP: a practical security checklist

MCP standardizes tool discovery and invocation; it does not grant database authorization. A database tool should enforce policy independently of the client and the model.

  1. Use a dedicated read-only database identity.
  2. Restrict visible tables and columns to the task.
  3. Supply tenant or user context from trusted application code, not from model arguments.
  4. Validate generated SQL before execution and enforce resource limits.
  5. Log policy decisions without exposing sensitive literals or credentials.
  6. Test denied writes, unauthorized columns, cross-tenant reads and expensive queries with synthetic data.

SQLGuardLLM exposes MCP tools for listing tables, describing tables, explaining queries and executing permitted reads. See the setup guide for supported options and a local demo.

The project is alpha software. Database-native permissions remain essential; a SQL firewall is an additional layer, not a substitute.

Source: https://github.com/jmmana/sqlguardllm