How to Configure Gemini CLI SQL Server Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gemini cli sql server permissions by making a dedicated database user. Then you place that user into a restricted read-only role. Teams often connect AI terminal tools to databases using their personal login keys. When a role is too broad, an AI agent can change or delete live data. It can also pull sensitive rows from every table in the database. How gemini cli sql server permissions work In SQL Server, a database user is the identity of a login inside a database. When an agent ne

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 permissions by making a dedicated database user. Then you place that user into a restricted read-only role. Teams often connect AI terminal tools to databases using their personal login keys. When a role is too broad, an AI agent can change or delete live data. It can also pull sensitive rows from every table in the database.

How gemini cli sql server permissions work

In SQL Server, a database user is the identity of a login inside a database. When an agent needs many databases on one instance, admins make a login in master. They then map that login to a SQL user in each target database. If the agent only needs one or a few databases, you have another option. You can make a contained database user with a password. This user does not tie back to a login in master. An admin must first turn on contained databases on the server and the database. SQL Server supports thirteen different types of database users in total.

Once the user exists, you assign it to fixed database roles. Every role, including the public role, has basic permission to reach the database. You cannot change the built-in rules assigned to fixed database roles. To grant read access, admins add the user to the datareader role. Members of this role can read all data from all user tables and views. If the agent must never change data, admins also add the deny datawriter role. Members of that role cannot add, change, or delete any table data. You should never put an AI tool in the owner role. The owner role allows all maintenance tasks and can even drop the whole database.

What native database roles solve and what they miss

Native roles are great at controlling who can log in to the server. They also set coarse boundaries around reading or writing across an entire database. By pairing a contained user with a read-only role, you block destructive write queries. The AI tool cannot drop tables or wipe out customer rows by mistake. If you use the deny datareader role, the user cannot read any user tables. It also cannot read views or metadata about those tables and views.

Still, native database roles leave a big operational gap during live sessions. Fixed roles decide access at login time, not per query in flight. A user in the datareader role can read every single user table and view. It can pull emails, phone numbers, card numbers, and national IDs in one query. Native roles do not rewrite matched fields in results before they reach the terminal. You also have to store static database passwords on the machine running the CLI. If you want a human to check a query first, roles cannot help. Database roles only check the user identity, not what each statement actually does.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why AI terminal agents need tighter query controls

Terminal agents run commands and queries fast to answer prompts and fix bugs. When an agent troubleshoots an issue, it often reads schema details and sample rows. If it uses a broad read role, sensitive strings go straight into the prompt. Static database keys sitting in local config files also create a risk for teams. Engineers need a way to inspect commands and mask fields like emails or card numbers. Combining basic SQL Server roles with query-level controls keeps your data safe during AI 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 sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.

With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.

Frequently asked questions

Should I use a login in master or a contained user for Gemini CLI?

Use a contained user if the agent only needs one or a few databases. Use a login in master if the agent must reach many databases on the instance. Remember that an admin must turn on contained databases on the server and database first.

Can I customize the built-in datareader role to hide specific columns?

No, you cannot change the permissions assigned to fixed database roles in SQL Server. Members of the datareader role can always read all data from all user tables and views. To restrict specific tables or columns, you must manage custom roles or explicit grants instead.

How do I make sure the Gemini CLI user cannot modify any table data?

Avoid adding the user to the datawriter or owner roles at all times. For an extra safeguard, add the database user to the deny datawriter fixed role. That role ensures the user cannot add, change, or delete data in user tables.

The query runs. The emails stay hidden.