How to Configure Cline SQL Server Read Only Access
You set up cline sql server read only access by creating a restricted database user. Then you add that user to the fixed database reader role in SQL Server. Coding agents like Cline run terminal commands and external tools on behalf of developers. Many teams first give the agent a shared admin account to speed up local work. Broad roles let the agent change tables, delete rows, or drop the whole database. A read-only setup stops the agent from changing data during normal coding tasks. How to s
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 cline sql server read only access by creating a restricted database user. Then you add that user to the fixed database reader role in SQL Server. Coding agents like Cline run terminal commands and external tools on behalf of developers. Many teams first give the agent a shared admin account to speed up local work. Broad roles let the agent change tables, delete rows, or drop the whole database. A read-only setup stops the agent from changing data during normal coding tasks.
How to set up cline sql server read only access
SQL Server separates server logins from individual database users. A login lets a person or tool enter the server instance itself. A database user is the identity that login uses inside one specific database. When someone needs many databases on one instance, admins create a login in master. Then they map a database user to that login in each target database.
For one or a few databases, admins can also create a contained database user. This user has its own password and does not tie to a login in master. Before doing this, an admin must enable contained databases on the server and database. SQL Server supports thirteen different types of database users for various login setups.
Once the user exists, you assign it to the fixed database reader role. Members of this reader role can read all data from all user tables and views. You can also add the user to the fixed deny data writer role. That role makes sure the user cannot add, change, or delete any table data. Fixed database roles have set permissions that admins cannot alter. Every database role, including the default public role, holds permission to enter the database.
After you set up the user, you give those login details to Cline. Cline can use these details through a local tool or a terminal command. Every query the agent runs will now follow the rules of that database user.
What native read-only roles solve and what they miss
Native database roles do a good job of stopping accidental writes and table drops. If Cline tries to run a delete or update command, SQL Server blocks it. Unlike the database owner role, a reader cannot change server settings or drop databases. This protects your tables from bad changes while the agent explores your schema.
Still, a native role only checks who logs in at the database level. It does not inspect what individual queries do while they run in flight. The fixed reader role lets the agent read every user table and view. You cannot change the permissions inside that fixed role to hide specific columns. If a table holds emails, phone numbers, card numbers, or national IDs, queries return them.
Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
A read-only user can still pull sensitive customer records into the agent context window. From there, those records travel to external model providers during normal chat turns. The agent also stores local credentials on the developer machine to reach the server. Anyone or any script on that machine can read those saved credentials. Native roles also do not require a human to approve risky read queries first. Finally, server logs only show the shared user name, not which developer ran Cline.
How to tighten agent database sessions in practice
Start by removing shared database owner accounts from all local agent config files. Create a dedicated read-only user for agent tasks instead of reusing human accounts. If you only need one database, consider a contained user to limit server reach. Pair the reader role with the deny writer role so write blocks stay firm.
Next, look at which tables the agent actually needs to read for its work. Because the fixed reader role covers all tables, sensitive tables keeps the session active by default. You may need custom roles or separate views if you must hide whole tables. Even then, native views require manual upkeep every time your schema changes. Teams that want field-level protection and per-query checks need controls outside the database role.
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, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I change the permissions of the fixed reader role in SQL Server?
No, SQL Server does not let you change permissions on fixed database roles. The fixed reader role always grants read permissions across all user tables and views. If you need custom table rules, you must build a custom role instead.
What is the difference between a standard SQL user and a contained user?
A standard SQL user maps to a server login stored in the master database. People use it when they need to reach many databases on one server. A contained user keeps its password inside the target database and needs no master login.
Does a read-only role stop Cline from reading sensitive columns?
No, the fixed reader role allows reading every column in all user tables by default. Queries will still return emails, phone numbers, card numbers, and national IDs in full. To hide those fields in results, you need data masking rewriting matched fields.
Related guides
In this post