How to Configure Gemini CLI SQL Server Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gemini cli sql server approval by pairing agent tool prompts with strict database roles. This dual setup stops the terminal agent from running bad queries without a human check. Teams often give local coding tools a personal database login to move fast. That broad login lets an AI agent alter tables or read secret rows by mistake. A safer path uses tight database roles and clear review rules before any query runs. How native gemini cli sql server approval works A terminal coding ag

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 gemini cli sql server approval by pairing agent tool prompts with strict database roles. This dual setup stops the terminal agent from running bad queries without a human check. Teams often give local coding tools a personal database login to move fast. That broad login lets an AI agent alter tables or read secret rows by mistake. A safer path uses tight database roles and clear review rules before any query runs.

How native gemini cli sql server approval works

A terminal coding agent works by running shell commands or calling external tools on your machine. When the agent wants to check a database, it prepares a command and asks you first. You look at the terminal prompt and say yes or no to that single action. If you approve the prompt, the tool sends the query using your local database login.

On the database side, SQL Server controls what that login can do after it gets in. A database user is the identity of a login when it connects to a database. For people who need many databases on an instance, a login in master is common. If the agent only needs one database, an admin can set up a contained database user. This user has a password and does not tie back to a login in master. First, the admin must turn on contained databases on the server and the target database.

Once the user exists, you assign a fixed database role to limit what the agent does. Microsoft SQL Server offers fixed roles with set rules that admins cannot change. A reader role lets the user read all data from all user tables and views. A writer role lets the user add, delete, or change data across all user tables. An owner role can run all maintenance tasks and can even drop the whole database. Admins can also assign deny roles that block reading or writing across user tables.

What native roles solve and what they miss

Native database roles and local CLI prompts solve the first layer of risk. They decide which user logs in and set a hard ceiling on table rights. If an agent uses a read-only role, it cannot drop a table or delete rows. Local terminal prompts also give the developer a chance to stop a bad shell command.

Approval Chains & Escalation + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Yet this native setup leaves a major operational gap during real work. Fixed database roles apply to every user table and view at the same time. A reader role lets the agent pull sensitive emails, phone numbers, and card numbers from any table. Local terminal prompts also create fatigue when an agent runs dozens of steps in a row. Developers start clicking yes out of habit, or they turn on auto-run flags to save time. Also, a local prompt only checks the shell command on one laptop. It does not give a central team a way to approve high-risk queries across the company. Native logins also require putting database passwords or keys on the local machine where the agent runs.

Why query-level checks and data masking matter

True safety for AI database tasks needs controls that inspect each statement in flight. When an agent sends a read query, the system should check the exact tables and columns requested. Masking rules can then rewrite matched fields like emails or national IDs in the results. If the agent tries to run a write query, a central review rule can pause the statement. A teammate can then check the exact SQL statement and approve it before the database runs it. This separates routine read tasks from high-risk changes without sharing broad database logins on user laptops.

Add runtime guardrails beside SQL Server

Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev sits inline in the TDS protocol beside the database as a sidecar for your SQL Server. For every query an agent or human runs in production, hoop.dev decides whether to pass, mask, block, or escalate it for review.

With hoop.dev SQL Server controls, rules refuse banned statements before they run, hold risky queries for human review, and mask matched sensitive values in supported result columns in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.

Frequently asked questions

Can I limit an AI agent to read-only queries in SQL Server?

Yes, you can add the database user to the fixed reader role in SQL Server. You can also add the deny writer role to make sure it never changes table data. Keep in mind that the fixed reader role still reads all user tables and views.

Why are local CLI prompts not enough for database approval?

Local prompts rely on the person sitting at the keyboard to spot bad SQL code every time. They do not leave a central audit log for the security team to check later. They also require storing real database credentials on the local machine.

Should an AI agent use a master login or a contained user?

A contained database user is better when the agent only needs one or a few databases. It keeps the user inside that specific database instead of linking to the master server login. An admin must enable contained databases on the server before you create this user.

The query runs. The emails stay hidden.