Agent Tool Security
Securing agent access to internal data sources — SQL injection prevention, MCP tool definitions, JWT-scoped permissions, row-level security, and audit logging for agentic queries against databases like Snowflake.
Overview
Why agent data access is different
Letting an agent query internal databases is harder to lock down than securing human-initiated API requests. The agent writes its query from a natural-language instruction, and that instruction may have been manipulated through prompt injection. The result is a direct path from untrusted user input to your most sensitive internal data.
That path has a fixed set of stops, and each one is a place to put a control.
Five layers sit along that path. Each stops a different thing and is enforced by a different part of the system.
- MCP tool definition: JSON Schema validation stops raw SQL and calls to unapproved tables.
- Parameterized queries: the tool implementation stops SQL injection through filter values.
- JWT-scoped credentials: the auth service and the tool stop access beyond the session's scope.
- Row-level security: the database itself stops rows outside the tenant or data scope.
- Audit logging: a log stream with anomaly detection catches exfiltration that passes every other control.
The rest of this chapter takes them one at a time, starting with where an attacker gets in.
Interview questions
- Walk me through how you would securely give an agent access to query our internal Snowflake database without exposing us to SQL injection or data leaks.
- How does MCP (Model Context Protocol) enforce tool-level security boundaries for an agent?
Sign up free to read the full topic
More MLOps & LLMOps topics
- Agent Loop Prevention
- Azure Machine Learning Platform
- Data Versioning and Dataset Management
- DevOps to MLOps Transition
- Feature Stores
- GitOps for Models: Versioned Rollouts with Eval Gates
- Hyperparameter Tuning and AutoML
- Internal ML Platforms: Golden Paths for Model Teams
- LLM Serving
- LLMOps
- ML Experiment Tracking
- ML Governance and Compliance
Start free on Cariara · Coding problems · System design studio