How to Configure Semantic Kernel SQL Server Approval
You set up semantic kernel sql server approval by pairing app filters with database roles. Your app pauses before running a query until a human reviewer clicks approve. Many teams start by giving their AI agent a single shared database login. If that role is too broad, one bad prompt can change or delete data. A safer setup uses strict database roles and human checks for risky commands. How semantic kernel sql server approval works with native roles First, you need to set up how the agent log
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.
You set up semantic kernel sql server approval by pairing app filters with database roles. Your app pauses before running a query until a human reviewer clicks approve. Many teams start by giving their AI agent a single shared database login. If that role is too broad, one bad prompt can change or delete data. A safer setup uses strict database roles and human checks for risky commands.
How semantic kernel sql server approval works with native roles
First, you need to set up how the agent logs in to SQL Server. In SQL Server, a database user is the identity of a login. When an agent needs many databases on an instance, teams use a SQL login. This login lives in the master database. If the agent only needs one database, you can use a contained database user. A contained user has a password and does not tie to a master login. An admin must enable contained databases on the server and database first. SQL Server supports thirteen types of database users in total.
Next, you assign the agent user to a fixed database role. The db_datareader role lets a user read all data from all user tables. It also lets the user read all views. If the agent must write data, teams often look at the db_datawriter role. Members of db_datawriter can add, delete, or change data in all user tables. You cannot change the permissions assigned to fixed database roles. Also, every role, including the public role, has permission to connect. You should avoid the db_owner role for AI agents. A db_owner member can run all maintenance tasks and even drop the database.
Inside your app, the agent framework manages the tool calls. When the model wants to run a SQL statement, it triggers a function. You can add a filter step before the function sends the query. This step pauses the run and sends the SQL text to a human reviewer. The reviewer checks the statement and approves or denies the action.
What native roles solve and what they leave open
Native roles and app filters solve basic login control. They decide which app can log in to the database. Fixed roles like db_datareader also block write commands at the database engine level. Meanwhile, you can use db_denydatawriter to stop a user from changing any table data. You can also use db_denydatareader to block all reads from user tables and views.
Approval Chains & Escalation + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, this native setup leaves a major operational gap in production. A database role applies the exact same rules to every query in a session. It decides who logs in, not what individual statements do in flight. If an agent needs db_datawriter for one task, it can modify all user tables. Native fixed roles cannot require a human check for just one risky delete statement. Also, db_datareader reads every column in every user table by default. It does not rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs. App filters help, but developers must build and maintain that review logic across every app. If someone runs a script outside the app, those code filters do not run.
How to design a safer query review workflow
To keep data safe, separate read tasks from write tasks. Give your standard agent identity the db_datareader role by default. When a task needs to change data, require an explicit approval step. The reviewer should see the exact SQL query and the user identity. Make sure your system logs who approved the query and when it ran. Also, apply data masking to rewrite emails and card numbers in query results. This keeps sensitive values out of model prompts while allowing normal read tasks.
Govern SQL Server queries and responses in flight
Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev is an open-source proxy that sits next to SQL Server as a sidecar for your SQL Server. It inspects TDS batches and parameterized queries in real time.
With hoop.dev guardrails and hoop.dev data masking, banned statements are refused with your message. Matched sensitive fields in supported result columns are masked in memory, and each decision is logged per listener. Check out the code on GitHub.
Frequently asked questions
Can I edit the permissions of the db_datareader role for an agent?
No, SQL Server does not let you change permissions on fixed database roles. If db_datareader is too broad, you must create a custom role with specific grants.
What happens if an AI agent has the db_owner role?
The agent gains full control over the database. Members of db_owner can change settings, alter tables, and drop the entire database in SQL Server.
Should I use a standard login or a contained user for my agent?
Use a contained database user if the agent only needs one or a few databases. Use a login in master if the agent needs many databases on the instance.
Related guides
In this post