Connect Goose AI to SQL Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You can connect goose ai to sql server using a local database bridge. This setup lets the agent run queries using a standard database user and password. AI agents help teams write queries and inspect data fast. Yet direct database sessions bring real risks if an agent runs a bad command. You need clear rules for how the agent logs in and what it can read. How to connect goose ai to sql server in practice Goose is an local AI agent that runs tasks on your machine. It uses extensions to talk t

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 can connect goose ai to sql server using a local database bridge. This setup lets the agent run queries using a standard database user and password.

AI agents help teams write queries and inspect data fast. Yet direct database sessions bring real risks if an agent runs a bad command. You need clear rules for how the agent logs in and what it can read.

How to connect goose ai to sql server in practice

Goose is an local AI agent that runs tasks on your machine. It uses extensions to talk to outside tools and databases. To link it to your database, you set up a database extension first.

That extension acts as a bridge between the agent and the database server. The bridge takes prompts from the agent and turns them into database queries. It sends those queries over the network to your database instance.

Before the agent can log in, you must set up a database user. In SQL Server, a database user is the identity of a login. If the agent needs many databases, you create a login in the master database.

If it needs one or a few databases, you can use a contained user. A contained database user has a password and does not need a master login. An admin must turn on contained databases on the server and database first. Microsoft supports 13 types of database users for different access needs.

Security tradeoffs of static roles and live sessions

Once you create the user, you must assign a role to limit its actions. Many teams use fixed database roles to control what an agent can do. You cannot change the permissions assigned to fixed database roles.

All roles, including the public role, have basic permission to connect. To keep the agent from changing data, admins often pick the read-only role. Members of this role can read all data from all user tables and views.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If an agent needs to change records, admins might look at the writer role. Members of the writer role can add, delete, or change data in user tables. You should also avoid the owner role for AI agents. The owner role can do all maintenance tasks and can even drop the database.

You can also block access with deny roles. A deny read role stops the user from reading any user tables or views. A deny write role stops the user from adding, changing, or deleting any data.

Fixed roles help, but they leave big gaps during an active AI session. A read role still lets the agent read every table in that database. If a table holds emails, phone numbers, or card numbers, the agent reads them.

Static database roles cannot rewrite sensitive fields like national IDs in query results. Also, storing a database password on a laptop puts that key at risk. Any local app or script could read the file and steal the database password.

Teams need a way to inspect every query before it hits the database. They also need data masking that rewrites emails and card numbers in query results. Adding an approval step for write queries keeps the database safe from agent mistakes.

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

What database role should I give an AI agent in SQL Server?

Start with the fixed read role so the agent can only read user tables. Add a deny write role to make sure it cannot change or delete data. Never give an AI agent the database owner role.

Should I use a standard login or a contained user for Goose?

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

Why is a read-only role not enough for AI database access?

A read role allows access to all user tables and views in the database. The agent can still pull sensitive data like phone numbers, emails, and card numbers. You need field masking to rewrite those values in the results before they return.

The query runs. The emails stay hidden.