How to Configure CrewAI SQL Server Sandbox
To set up a crewai sql server sandbox, create a restricted database user. Then give that user a read-only database role for your agent tools. Many teams start by giving agents a shared admin account during testing. That broad role lets an autonomous task change or drop whole tables by mistake. How a crewai sql server sandbox works with database roles In SQL Server, a database user is the identity of a login inside a database. When an account needs many databases on one server, teams make a ma
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To set up a crewai sql server sandbox, create a restricted database user. Then give that user a read-only database role for your agent tools. Many teams start by giving agents a shared admin account during testing. That broad role lets an autonomous task change or drop whole tables by mistake.
How a crewai sql server sandbox works with database roles
In SQL Server, a database user is the identity of a login inside a database. When an account needs many databases on one server, teams make a master login. When an agent only needs one database, a contained database user is an option. An admin must turn on contained databases on the server and the database first. Microsoft supports thirteen types of database users in total.
Once you create the user, you assign a fixed database role to limit actions. You cannot change the permissions built into these fixed database roles. Every role, including the public role, comes with permission to enter the database. A user in the read-only role can read all data from all user tables. That same user can also read data from all views in the database. By contrast, a writer role can add, delete, or change data in user tables. An owner role can run all maintenance tasks and even drop the whole database.
To lock down the sandbox further, you can add a deny writer role. A user with that role cannot add, modify, or delete any table data. There is also a deny reader role that blocks reading tables, views, and metadata. You assign your agent user to these roles through standard role commands. Next, you pass those user credentials to the database tool inside your agent crew.
What native roles solve and what they leave open
Using a read-only database user stops an agent from deleting rows or dropping tables. It also keeps the agent inside one target database when you use contained users. This setup is a good first step for any team running automated database tasks.
Kubernetes API Server Access + AI Sandbox Environments: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, fixed database roles only decide who can log in and read tables. They do not inspect what individual queries do while they run in flight. A read-only role lets the agent read every user table and view at once. If a table holds sensitive customer data, the agent pulls all of those rows. The agent then sends those raw phone numbers, emails, and card numbers to the model. Native roles also cannot pause a single risky query for a human to check. Finally, database logs show the shared agent login, not which task triggered the query.
Why agent queries need checks in flight
Agents write their own SQL queries based on user prompts and table schemas. Even when a prompt looks safe, the generated query can join huge tables together. A bad join can lock up database memory and slow down other apps. Because fixed roles apply to the whole database, they cannot block bad query patterns. Teams need a way to inspect each statement and mask sensitive fields in results. Rewriting matched fields like national IDs or emails keeps private data out of prompts.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.
Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I edit the permissions of a fixed database role in SQL Server?
No, SQL Server does not let you change the permissions of fixed database roles. If you need custom table rules, you must build a custom role instead.
What is the difference between a login user and a contained user?
A standard user links to a server login stored in the master database. A contained user has a password stored inside the target database itself. This keeps the agent tied to one database without needing a master server login.
Does a read-only role hide sensitive columns from my AI agent?
No, the fixed read-only role gives read access to all user tables and views. To hide specific fields like card numbers or emails, you need result masking.
Related guides
In this post