How to Configure Cursor SQL Server Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up cursor sql server permissions by creating a restricted database user. Then you assign that user to a read-only database role for the AI agent. Many engineering teams give their coding assistant a shared admin login to save time. That broad role lets the agent change tables or drop the entire database. A safe setup limits what the AI tool can read and write from the start. How cursor sql server permissions work in practice SQL Server separates server logins from individual database

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 cursor sql server permissions by creating a restricted database user. Then you assign that user to a read-only database role for the AI agent. Many engineering teams give their coding assistant a shared admin login to save time. That broad role lets the agent change tables or drop the entire database. A safe setup limits what the AI tool can read and write from the start.

How cursor sql server permissions work in practice

SQL Server separates server logins from individual database users. A login lets a person or tool enter the server instance. A database user is the identity of that login inside one specific database. When someone needs to reach many databases, admins create a login in master. When an agent only needs one database, admins can create a contained user. A contained database user has its own password and does not need a master login. An admin must enable contained databases on the server and the database first.

Once the user exists, you control its actions through fixed database roles. You cannot change the base rules inside these built-in roles. Every database role includes the basic right to connect to the database. To keep an AI agent safe, admins often use the read-only role. Members of this role can read all data from all user tables and views. If you also add the deny write role, the user cannot change any data. You should never put an AI coding agent in the database owner role. The owner role can change settings, run maintenance, and drop the whole database.

How AI coding agents reach your database

Cursor and other AI coding agents reach external databases in two main ways. First, developers often connect the editor to a database through a local tool server. Second, the agent can run database scripts through its built-in shell tool. In both cases, the developer puts a database connection string on their laptop. That string holds the username and password for the SQL Server user.

When you ask the agent to check a schema, it uses those saved keys. The database checks the user role and allows or blocks the query. If the user has write rights, a bad prompt can delete production rows. Even if the user only has read rights, new risks appear right away. The built-in read role grants access to every user table and view. It does not hide sensitive columns from the AI coding agent.

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 database roles leave open

Native SQL Server roles decide who can log in and read tables. They do not inspect what individual queries do while they run. When an agent has the read role, it can select customer rows in bulk. Those query results often include emails, phone numbers, card numbers, or national IDs. The editor then sends those raw results straight to an external AI model.

Static connection strings on developer laptops also create a big security gap. Anyone who finds that local file can use the database password from their machine. Shared logins also make it hard to see which person ran a heavy query. Database logs only show the shared agent username instead of the real developer. Teams need a way to check queries in flight and rewrite sensitive fields.

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

Should I use a login or a contained user for Cursor?

Use a contained database user when the agent only needs one database. It keeps the user inside that single database without a login in master. Use a standard login only when the agent must query many databases at once.

Does the read-only role hide sensitive customer columns from AI agents?

No, the built-in read role lets the user read all user tables and views. If a table holds emails or card numbers, the agent will read them. You need extra controls or field masking to rewrite those values in results.

How do I stop an AI agent from modifying SQL Server tables?

Assign the agent user to the read role and the deny write role. The deny write role blocks the user from adding, changing, or deleting table data. Never give the agent user the write role or the database owner role.

The query runs. The emails stay hidden.