How to Configure Semantic Kernel SQL Server MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a semantic kernel sql server mcp server, link your agent host to the database tool. Next, assign a dedicated SQL Server user with strict read permissions for that tool. Many teams start by giving the agent a broad database owner account during testing. This quick shortcut creates big risks when the agent runs in production. An agent with full write rights can change or drop tables by mistake. A safe setup requires a dedicated database login with limited table roles. How a semantic ke

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.

To set up a semantic kernel sql server mcp server, link your agent host to the database tool. Next, assign a dedicated SQL Server user with strict read permissions for that tool. Many teams start by giving the agent a broad database owner account during testing. This quick shortcut creates big risks when the agent runs in production. An agent with full write rights can change or drop tables by mistake. A safe setup requires a dedicated database login with limited table roles.

How a semantic kernel sql server mcp server works

Semantic Kernel acts as the brain that connects your AI model to outside tools. The Model Context Protocol server works as the bridge to your SQL Server database. When a user asks a question, Semantic Kernel picks the right database tool. The tool then logs in to SQL Server and runs a query. SQL Server checks the database user identity before it returns any rows.

In SQL Server, a database user represents the login identity inside a specific database. Teams often create a standard SQL login in the master database first. That approach works well when an account needs to reach many databases on one instance. For one or a few databases, a contained database user is another good option. A contained user has a password and does not tie to a master login. An admin must turn on contained databases on the server and database first. Microsoft SQL Server supports thirteen different types of database users for these setups.

After creating the user, you must assign a database role. Fixed database roles control what the agent can read or change. Every role, including the default public role, includes basic connect rights. You cannot change the built-in permissions assigned to fixed database roles. To keep the agent safe, add the user to the read-only role. Members of this role can read all data from all user tables and views. You can also use a deny write role to block data changes. Never put the agent in the owner role, which can drop the whole database.

What native roles solve and what they miss

Native SQL Server roles solve the first step of database security. They control who can log in and which tables they can read. By combining a read role with a deny write role, you stop bad deletes. Your AI agent can answer questions from live data without changing records.

Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, native database roles leave a big gap during live agent runs. Fixed roles apply to whole tables rather than single columns or live queries. A user in the standard read role can read every user table and view. If a table holds emails, phone numbers, card numbers, or national IDs, the query pulls them. Data masking is needed to rewrite matched fields in results before the model processes them. Also, static database passwords sit in app settings on the host machine. Native roles decide who logs in, not what each query does in flight.

Steps to harden your agent database setup

Start by creating a dedicated user just for your AI agent workflow. Do not share this account with web apps or human engineers. Keep the account out of the writer and owner roles at all times. If a sensitive table holds secrets, create a custom role with narrower rights. You can also place the user in the deny read role for specific scopes. Review your database logs often to see which queries the agent sends. Finally, plan how to mask private fields like emails and card numbers in query results.

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

What database role should I give my SQL Server MCP tool?

Assign the built-in read-only role so the tool can read user tables and views. Also assign the deny write role so the user cannot add, change, or delete data.

Should I use a standard SQL login or a contained user?

Use a standard login in master if the tool queries many databases on one server. Use a contained database user if the tool only needs one or a few databases.

Why is the database owner role risky for AI agents?

Members of the owner role can run all maintenance tasks and change settings. They can even drop the entire database in SQL Server if a prompt goes wrong.

The query runs. The emails stay hidden.