How to connect AI assistant to SQL Server
Everyone talks about AI, all your town halls are about AI, and you’re sitting here at your desk wondering, “What do I do about AI other than rephrasing the emails and teams chats?”
I got you! Here is something exciting!
Microsoft released the Model Context Protocol (MCP) for SQL Server in June 2025.
I checked it out to see what it was all about and I was astonished. Turns out, you can connect an AI assistant like Claude directly to SQL Server and ask it questions in plain English. Claude then responds with what it finds about your connected SQL Server instance.
You will understand what I’m talking about in a few minutes!
What is MCP?
In simple English, it is a medium that lets AI interact with other tools, the tool in this case is SQL Server. So, for AI to talk to SQL Server, it needs MCP to do the interaction.
Ask questions: AI—>MCP—>SQL Server.. and sends info back .. AI<—MCP<—SQL Server.
There is MCP for all different technologies like PostGres, Kubernetes, etc, in this blog when I say MCP it is only about MCP for MSSQL server.
Alright, let’s go ahead and see how to get this all setup and working.
Setup MCP server
Install Node.js
Use Node.js to build MCP server
Here is the link to download Node.js - https://nodejs.org/en/download
This will be the MCP server that connects AI to SQL Server
There are other options to build MCP, but I’m using Node.js. Honestly, I had no idea how Node.js worked until I installed it. So if you're in the same boat, that’s totally fine, you’ll learn as you experiment, just like I did.
Install git
To setup things on Node.js MCP server, gitbash is needed to run/build/install packages, dependencies, etc.
Here is the link to download git - https://git-scm.com/downloads
Build MCP server
Clone Repo:
I’m cloning GitHub repository from Microsoft’s blog here.
Open gitbash and run the script below./* https://devblogs.microsoft.com/azure-sql/introducing-mssql-mcp-server */ git clone https://github.com/Azure-Samples/SQL-AI-samples.git
Go to Node project:
After cloning, you will find Node project directory.
On my machine, the Node project is here:C:\Users\harip\SQL-AI-samples\MssqlMcp\Node
In gitbash, navigate to the appropriate path on your machine:
cd /c/Users/harip/SQL-AI-samples/MssqlMcp/Node/
3. Install Dependencies:
Run ‘npm install’ - npm is node package manager and a library for .js packages. npm install command installs the packages and its dependencies.
After this step, a new
dist
folder will be created inside theNode
directory:C:\Users\harip\SQL-AI-samples\MssqlMcp\Node\dist
Add Tools to the Project:
MCP originally comes with 8 tools to connect, create, list tables etc., I added additional 14 tools from Olivar Flindall’s github. Credits to Olivar for some great ideas!!
Download the 14 extra tools and place them in thetools
directory:C:\Users\harip\SQL-AI-samples\MssqlMcp\Node\src\tools
Replace
index.ts
with a modified Version:You’ll find the original
index.ts
file here:C:\Users\harip\SQL-AI-samples\MssqlMcp\Node\src
I’ve modified the following in index file:Removed Entra authentication
Added SQL authentication using username/password
Enabled Trust Server Certificate
Added 14 tools from above
You can download the modified
index.ts
here and replace the original with it.Build the project:
Run this command in Git Bash: “npm run build”
This will rebuild index.js file in dist folder based on modified index.ts file.index.js file location -
C:\Users\harip\SQL-AI-samples\MssqlMcp\Node\dist\index.js
Restart MCP server using - “npm run start”
MCP server is now ready to use.
Now let’s get AI tool setup.
Setup AI tool
Install Claude AI
This is the AI assistant desktop tool to install - https://claude.ai/download
Again you could choose either Visual Studio Copilot or Claude
Claude config file is here - C:\Users\harip\AppData\Roaming\Claude\claude_desktop_config.json
I modified this file to include 2 SQL Servers and gave username, password to connect with.
Updated claude_desktop_config.json here.
If Claude is already running, don’t just close the window, it won't fully exit.
Terminate it from Task Manager to ensure your config changes are picked up on restart.Now open up claude - you should see sql servers connected and the number of tools
Here are the tools that it sees, the ones from index.ts file
Now you can verify by asking it to check for connectivity
I caused TempDB contention(insert wicked laugh here) on SQL 2025 and asked it to check if there is any slowness on the instance. I didn’t tell Claude that I caused contention, I just asked it to checked for slowness.
It does a bunch of checks
Mentions about pagelatch contention in the top, as expected - SWEEEET!!!
Ends up providing some recommendations which are not great.
I did a bunch of demos including blocking, deadlocks, comparing the number of connections between instances, etc.
My finding: It is GREAT at troubleshooting and AVERAGE at providing solutions.
This looks like a great start to me and we could build from there.
I’m planning to add more tools to the index for in-depth troubleshooting.
Summary
MCP connects AI to SQL Server
Install Node.js and Git to build and setup MCP server
Add troubleshooting scripts/tools as needed
Install Claude AI as an assistant tool to ask questions in plain English
Configure Claude AI config file to connect to SQL Server instances
Claude AI gets answers from SQL Server via MCP
Check connectivity from Claude
Ask questions!
Resources
https://github.com/haripriyasb/MCPSQLServer/blob/main/src/index.ts
https://devblogs.microsoft.com/azure-sql/introducing-mssql-mcp-server/
https://devblogs.microsoft.com/azure-sql/mssql-mcp-server-in-action-susans-journey/
https://oli-the-dba.com/how-i-accidentally-built-a-better-database-admin-than-myself/
Thanks for reading,
Haripriya Naidu.