How to Configure Semantic Kernel SQL Server Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up semantic kernel sql server permissions by making a dedicated database user. Then you put that user into a strict role before the agent runs queries. Teams often start by giving the AI app a broad admin login to move fast. When roles are too broad, a bad prompt can alter rows or drop a database. Good role design stops an agent from changing tables it only needs to read. How semantic kernel sql server permissions work Semantic Kernel uses plugins and functions to talk to your data st

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 permissions by making a dedicated database user. Then you put that user into a strict role before the agent runs queries. Teams often start by giving the AI app a broad admin login to move fast. When roles are too broad, a bad prompt can alter rows or drop a database. Good role design stops an agent from changing tables it only needs to read.

How semantic kernel sql server permissions work

Semantic Kernel uses plugins and functions to talk to your data stores. The framework does not manage database rules on its own. Instead, it relies on the connection string you pass to your data plugin. That string holds the identity that SQL Server checks at login time.

In SQL Server, a database user is the identity of a login inside a database. There are 13 types of database users you can pick from. If your agent needs many databases on one instance, use a login in master. Then map a SQL user to that login in each target database.

If the agent only needs one database, you can use a contained database user. This is a SQL user with a password that does not need a master login. An admin must first turn on contained databases on the server and the database.

Next, you assign the user to fixed database roles to control table access. All roles, including the public role, have permission to connect. You cannot change the permissions built into fixed database roles. If your AI agent only answers questions, put it in the read-only role. Members of this role can read all data from all user tables and views.

To block writes for sure, also add the user to the deny writer role. Members of the deny writer role cannot add, change, or delete any table data. Avoid the owner role for AI agents. The owner role can do all maintenance tasks and even drop the database.

Kubernetes API Server Access + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native SQL roles solve the basic problem of who can log in. They also draw a clear line between reading tables and writing to them. A read-only role stops an AI plugin from running delete or update statements. This protects your tables if a language model writes a bad command.

Still, static roles leave a big operational gap during live queries. A database role decides who logs in, not what individual statements do in flight. A user in the standard reader role can read every user table and view. It can pull emails, phone numbers, card numbers, or national IDs into the model prompt.

Also, if an agent needs to update one status column, the writer role is risky. The fixed writer role lets the user add, delete, or change data in all tables. Native roles also do not tie a shared app login back to the human user. If ten people use the same bot, the database log shows only one SQL user. Teams need a way to check queries in flight and mask sensitive fields in results.

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

Should I give an AI agent the database owner role?

No, never give an AI agent the database owner role. That role can run all maintenance tasks and can even drop the whole database.

How do I make a Semantic Kernel SQL plugin read-only?

Create a dedicated database user for the plugin connection string. Add that user to the fixed data reader role and the deny data writer role.

When should I use a contained database user for an AI app?

Use a contained user when the agent only needs one or a few databases. It logs in with a password and skips the master database login step.

The query runs. The emails stay hidden.