June 26th, 2025
0 reactions

Introducing MSSQL MCP Server (Preview)

Arun Vijayraghavan
Principal Product Manager

The next leap in data interaction isn’t just about efficient processing; it’s about intuitive and meaningful conversation with your own data. For years, the true power of SQL Server databases has been locked behind complex query languages and specialized tools, accessible primarily to developers and database administrators. But what if anyone, regardless of their technical expertise, could simply ask their database a question and get an intelligent, actionable response? 

 We’re thrilled to offer you a first practical look at MSSQL MCP Server. This powerful capability, currently in a preview phase and available as an open-source project, transforms how you engage with your SQL Server database, bringing its power directly to AI agents. 

What is MCP 

The Model Context Protocol (MCP) is an open standard designed to enable seamless interaction between AI agents and external resources. These resources are defined as MCP clients (integrated within AI applications) and MCP servers (which expose external systems’ functionalities). The advent of MCP revolutionizes integration between AI systems and diverse data sources, tools, and more, offering a powerful “write once” approach. This means developers can build a single MCP server for any system, and AI applications can connect to it with a single MCP client, streamlining what was once a complex web of bespoke integrations. 

An MCP Server securely exposes specific functionalities such as “tools”, “resources” and “prompts” that AI models can dynamically discover, understand, and invoke through natural language. This standardized communication layer empowers AI to interact with complex systems in a controlled and efficient manner. 

 For more information on MCP, visit the protocol’s website and GitHub organization. 

MSSQL MCP Server: AI-Agent’s Action Gateway 

Building on the foundation of the Model Context Protocol, the Microsoft SQL Server – Model Context Protocol (MSSQL MCP) Server extends this paradigm directly to your diverse SQL environments, offering a robust and controlled gateway for AI assistants. Available in both .NET and Node.js implementations, MSSQL MCP Server empowers developers with flexibility.  

For this blog post, we will be demonstrating how to integrate and work with the Node.js-based MSSQL MCP Server. Detailed instructions and guidance for the .NET version can be found in the GitHub repository’s README file. 

This powerful gateway provides seamless connection across on-premises SQL Server, Azure SQL Database, and SQL Database in Microsoft Fabric, allowing you to switch environments effortlessly with a simple connection string change. Through its robust architecture, it directly enables capabilities from schema management to data manipulation, all accessible via natural language prompts.

 

MSSQL MCP in Action

Implemented Tools 

The MSSQL MCP Server provides a comprehensive suite of tools, each designed to perform specific database operations. These are the building blocks that MCP Client (Agent Host) can use to interact with your SQL Server: 

Tools

Purpose 

List Tables  Lists all tables present in the connected SQL Server database instance. This is invaluable for AI to understand the database’s landscape and identify relevant data sources for a given query. 
Describe Table  Provides detailed schema information, column definitions, data types, and other metadata for a specified table. This allows the AI to accurately interpret table structures and formulate precise queries or data manipulation commands. 
Create Table  Enables the creation of new tables in the database. You can instruct the AI to define table names, columns, and their types, streamlining database setup and schema evolution directly through natural language. 
Drop Table  Facilitates the deletion of existing tables from the database. This tool is useful for cleaning up test environments or managing schema changes, always with the necessary confirmations for security.
Insert Data  Insert new rows of data into a specified table. This allows for the population of tables with transactional data, sample data for testing, or any other data entry requirements, all via conversational commands. The tool supports batch mode, enabling the insertion of multiple records in a single operation for improved efficiency and scalability.
Read Data  The primary tool for querying and retrieving data from a table. It allows specifying conditions, limits, and orderings, enabling AI to fetch specific datasets for analysis, reporting, or display. This effectively replaces the need to learn complex SELECT statements, with natural language requests.
Update Data  Modifies existing data within a specified table based on defined conditions. This empowers AI to perform data maintenance tasks, correct entries, or apply updates efficiently and accurately. 
Create Index  Create a new index on a specified table to improve query performance. This tool allows users to define indexes on one or more columns, enabling faster data retrieval and optimized execution plans for read-heavy workloads.

Integration with MCP Clients 

The practical utility of the MSSQL MCP Server truly shines when integrated with AI-powered development environments like Visual Studio Code and conversational AI platforms like Claude Desktop. 

Follow the steps below to configure the Node.js-based MSSQL MCP Server with an MCP Client (Agent Host) of your choice. Before integrating, you need to build the MSSQL MCP Server locally 

  1. Download and install node.js. 
  2. Download and configure Git. 
  3. Clone the MSSQL MCP Server GitHub repository and open a terminal or command prompt to execute the following command:  
git clone https://github.com/Azure-Samples/SQL-AI-samples.git

     4. On a terminal, navigate to the directory that contains the node project, 

cd SQL-AI-samples/MssqlMcp/Node

      5. Install the dependencies and build the project by executing the following command,

npm install

The npm install command, when run in a project with a prepare or post install script defined in package.json (which is common for build processes), will often automatically execute a build step. Therefore, running npm run build separately might not be necessary if the project’s package.json is configured this way. If you encounter issues, refer to the project’s specific package.json scripts. 

      6. After the build is successful, locate the index.js file within the newly created dist folder. Copy and save its fully qualified path; you will need in an upcoming step.

 Visual Studio Code (GitHub Copilot) 

 Visual Studio Code, particularly with the GitHub Copilot Chat extension, offers robust native support for MCP servers. Here’s a quick overview of setting it up: 

  1. Download VS Code and setup GitHub Copilot. 
  2. Configure your MCP server in the `settings.json` using the example provided from the cloned repository as a reference. The configuration instructs VS Code on how to launch and communicate with your MSSQL MCP Server. Your MSSQL MCP Server needs to be configured with the appropriate connection details for your chosen SQL Server database (cloud, on-premises, or Fabric) as shown below,  
    { 
       "servers": {
          "MSSQL MCP": { 
               "type": "stdio",
               "command": "node", 
               "args": ["<<path/to/your/index.js>>"],
                "env": { 
                  "SERVER_NAME": "<<data_source>>", 
                  "DATABASE_NAME": "<<initial_catalog>>", 
                  "READONLY": "false" 
                 } 
            }
        }
    } 

  • Replace <<path/to/your/index.js>> with the actual fully qualified path to the index.js file.

          For example, C:\\demo\\SQL-AI-samples\\MssqlMcp\\Node\\dist\\index.js”

  • Replace <<data_source>> with your database server’s name (without the port). 

          For example, “demo-server.database.windows.net”  

  • Replace <<initial_catalog>> with your database name (example: “db-events”).
  • The default setting for READONLY is false. Changing this setting to true will include only read-only tools, such as read data, list tables, and describe table. 

3. Enable Agent Mode: 

In the VS Code switch to Agent mode. Click the Tools button and you should see “MSSQL MCP” listed as a MCP Server. Select it to make all the tools available for AI interaction. 

4. Start MCP Server:

Click on the Start button. You will find it in settings.json on top of your configuration as shown in image below. 

5. Interact with SQL Server: 

You can now use natural language prompts in the chat window, directly invoking the MSSQL MCP Server’s tools. For the first time You will be prompted to authenticate using Entra authentication. Ensure your database has necessary access for the authenticated Entra user. 

VSCODE MSSQL MCP02 image

Claude Desktop

Claude Desktop supports connecting to MCP servers, extending its conversational capabilities to your database. Configuring a Calude Desktop, typically involves updating a specific config file within Claude’s application data directory. Here’s a quick overview of setting it up: 

  1. Download and install Claude desktop. 
  2. Navigate to File -> Settings -> Developer and click Edit Config this should lead you to `claude_desktop_config.json` file.
  3. Configure your MCP server in the claude_desktop_config.json using the example provided from the cloned repository as a reference. The configuration instructs Claude desktop on how to launch and communicate with your MSSQL MCP Server. Your MSSQL MCP Server needs to be configured with the appropriate connection details for your chosen SQL Server database (cloud, on-premises, or Fabric) as shown below, 
     { 
        "mcpServers": {
           "MSSQL MCP": { 
              "type": "stdio",
              "command": "node", 
              "args": ["<<path/to/your/index.js>>"],
              "env": { 
                       "SERVER_NAME": "<<data_source>>", 
                       "DATABASE_NAME": "<<initial_catalog>>", 
                       "READONLY": "false" 
               } 
            }
        }
     }
  • Replace <<path/to/your/index.js>> with the actual fully qualified path to the index.js file.

          For example, “C:\\demo\\SQL-AI-samples\\MssqlMcp\\Node\\dist\\index.js”

  • Replace <<data_source>> with your database server’s name (without the port). 

          For example, “demo-server.database.windows.net”  

  • Replace <<initial_catalog>> with your database name (example: “db-events”).
  • The default setting for READONLY is false. Changing this setting to true will include only read-only tools, such as read data, list tables, and describe table. 

4. Restart Claude Desktop:

  • To close: Look for the Claude Desktop icon in your system tray (bottom right corner near the clock on Windows, or top right menu bar on macOS), right-click (Windows) or Control-click (macOS) it, and select ‘Quit’ or ‘Exit’.
  • To reopen: Find the Claude Desktop shortcut on your desktop, in your Start Menu (Windows), or in your Applications folder (macOS), and double-click it.

5. Interact with SQL Server: 

You can now use natural language prompts in the chat window, directly invoking the MSSQL MCP Server’s tools. For the first time You will be prompted to authenticate using Entra authentication. Ensure your database has necessary access for the authenticated Entra user. 

claude image

For more information on configuring Claude desktop, refer to the documentation.

With your MSSQL MCP Server seamlessly integrated with an AI agent client like VS Code or Claude, you’re now all set to witness its transformative power firsthand in a real-world scenario.

What’s Next?  Your First Conversation with Data

Once you’ve configured MSSQL MCP Server with your chosen MCP Client, the real magic begins. You don’t need to write a single line of SQL. Simply open your chat interface in Visual Studio Code (with Copilot Chat) or Claude Desktop and start interacting with your SQL Server database using natural language prompts. The power of your database is now just a conversation away.

Let’s try this out by asking a simple question such as, which database are you connected to?

MCP Client (Agent Host) Response

Claude Action image

Conclusion 

The release of MSSQL MCP Server (Preview) marks a significant milestone in how we interact with databases. By leveraging the open-standard Model Context Protocol, we’re democratizing access to SQL Server’s immense power, enabling direct, natural language conversations with your data through AI agents. This open-source project is set to transform workflows, making complex data operations intuitive and accessible for everyone. 

This announcement is just the beginning. In an upcoming blog post, we’ll dive deeper into a compelling real-world use case, demonstrating Agents at work with MSSQL MCP Server in action through the eyes of an event manager. We’ll show you how this innovation turns daunting data tasks into seamless, conversational experiences. 

We encourage you to explore MSSQL MCP Server, try out the integration steps, and start having your own conversations with your data today. The future of data interaction is here, and we can’t wait to see what you build! 

Author

Arun Vijayraghavan
Principal Product Manager

AI and Data Enthusiast | Passionate about leveraging data to build intelligent solutions

0 comments