How to Configure Amazon Q SQL Server MCP Server
You set up an amazon q sql server mcp server by linking your local agent to a database tool. You then pair that tool with a read-only SQL Server user. Many teams rush this step during early testing. They hand the agent a shared admin account to save time. Broad roles let an AI agent change tables, drop data, or read secret rows. A safe setup needs strict database roles and clear limits on every query. How the amazon q sql server mcp server setup works Amazon Q runs on the developer machine an
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 an amazon q sql server mcp server by linking your local agent to a database tool. You then pair that tool with a read-only SQL Server user. Many teams rush this step during early testing. They hand the agent a shared admin account to save time. Broad roles let an AI agent change tables, drop data, or read secret rows. A safe setup needs strict database roles and clear limits on every query.
How the amazon q sql server mcp server setup works
Amazon Q runs on the developer machine and talks to external tools through the Model Context Protocol. The MCP server acts as a local bridge between the AI agent and your SQL Server instance. When you ask a question in your editor, the agent picks a tool from the MCP server. The MCP server then opens a session to SQL Server using a login and a database user.
In SQL Server, a login lets an account enter the server instance itself. A database user is the identity of that login inside one specific database. When a user needs to reach many databases on one instance, teams create a login in master. When an agent only needs one database, admins can use a contained database user with a password. A server admin must turn on contained databases on the server and database first. Microsoft SQL Server supports thirteen types of database users in total.
Once the user exists, you assign it to a fixed database role. Fixed database roles have built-in permissions that you cannot change. Every role, including the default public role, holds the basic permission to connect. The standard read-only role allows the member to read all data from all user tables and views. A deny-read role blocks the user from reading any user tables, views, or metadata about them. A data writer role lets a member add, delete, or change data in all user tables. A deny-write role stops the user from adding, changing, or deleting any table rows. The database owner role can run all maintenance tasks and can even drop the entire database.
What native roles solve and what they leave open
Assigning a read-only role and a deny-write role stops the AI agent from changing or dropping tables. This step protects your data from bad updates or accidental deletes during a chat session. It also keeps the agent out of other databases when you use a single database user.
Still, native SQL Server roles only check who logs in at the start of a session. They do not inspect what individual queries do while they run in flight. A read-only role still lets the agent read every row in every user table and view by default. If a table holds customer emails, phone numbers, card numbers, or national IDs, the agent reads them. Those raw values then flow straight into the AI prompt context and out to the model provider.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native roles also require you to store a database password on the developer laptop. Anyone with access to the local config file can copy that password and run queries outside the agent. Also, a read-only user can still run heavy joins that lock up CPU and slow down production. Standard database roles cannot pause a risky query to ask a human for approval first. They also cannot rewrite matched fields in query results to mask emails or card numbers on the fly.
Steps to lock down your agent database workflow
Start by creating a dedicated SQL Server user just for your AI coding agent. Never reuse a human engineer login or an app service account. Next, place that user in the read-only role and add the deny-write role for safety. If your database holds sensitive tables, use the deny-read role or custom schema rules to block them. Finally, check how credentials live on developer machines so raw passwords do not sit in plain text files.
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 runs beside the database as a sidecar for your SQL Server and checks TDS traffic without changing how clients log in.
With hoop.dev SQL Server controls, rules refuse banned statements before they run and can hold risky queries for human review. Matched sensitive values in supported result columns are masked before they reach the client. 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
Should I give the MCP server the database owner role?
No, you should never assign the database owner role to an AI agent. That role can run all maintenance tasks and can drop the entire SQL Server database.
Does a read-only SQL Server role hide sensitive customer columns?
No, the built-in read-only role lets the user read all data across all user tables and views. It does not rewrite or mask fields like emails, phone numbers, or card numbers in results.
What is the difference between a standard login and a contained user?
A standard SQL user links to a server login stored in the master database. A contained user stays inside one database with its own password, once an admin turns the feature on.
Related guides
In this post