MSSQL MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to interact with both local SQL Server and Azure SQL Database through natural language.
🚀 What Makes This Special?
This MCP server solves a critical limitation of existing solutions by supporting both local SQL Server and Azure SQL Database connections. While the original Azure-Samples implementation only works with Azure SQL Database, this enhanced version enables:
🏠 Local Development: Connect to local SQL Server instances using username/password authentication
☁️ Azure Cloud: Full Azure SQL Database support with Azure AD authentication
🔄 Seamless Switching: Use the same tools for both environments
Quick Example:
📦 Quick Start
Prerequisites
Node.js 18+
SQL Server (local) or Azure SQL Database
AI Assistant: Claude Desktop or VS Code Agent
Installation
Configuration
Local SQL Server:
Azure SQL Database:
⚙️ AI Assistant Setup
Claude Desktop
Add to claude_desktop_config.json
:
Local SQL Server:
Azure SQL Database:
VS Code Agent
Create .vscode/mcp.json
with similar configuration using "type": "stdio"
.
Config Locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
📋 Environment Variables
Variable | Required | Description | Example |
| ✅ | SQL Server hostname |
or
|
| ✅ | Target database name |
|
| 🔄 | Username (local SQL Server only) |
or
|
| 🔄 | Password (local SQL Server only) |
|
| ❌ | Restrict to read-only operations |
or
(default) |
| ❌ | Trust self-signed certificates |
or
(default) |
🔄 = Required for local SQL Server, not needed for Azure SQL Database
✅ Verification
🛠️ Available Tools
Tool | Purpose | Example |
| Query data with SELECT | "Show customers from New York" |
| Add new records | "Insert new product with price $99" |
| Modify existing data | "Update order status to shipped" |
| Create new tables | "Create table for reviews" |
| Add database indexes | "Create index on customer email" |
| Remove tables | "Drop temporary table" |
| Show all tables | "What tables exist?" |
| Show table structure | "Describe customers table" |
Security Features:
✅ SQL injection prevention
✅ Query validation and sanitization
✅ Required WHERE clauses for updates
✅ Read-only mode support
📚 Documentation
For detailed information, see our comprehensive guides:
Usage Examples - Practical examples and real-world scenarios
Advanced Configuration - Complex setups and enterprise deployment
Best Practices - Performance optimization and security guidance
Troubleshooting - Common issues and solutions
Platform Notes - Windows, macOS, Linux, and Docker specifics
� Credits and Attribution
Original Work
This project is a fork of the Azure-Samples/SQL-AI-samples repository, specifically building upon the MssqlMcp implementation created by Microsoft and the Azure team.
Original Repository: Azure-Samples/SQL-AI-samples
Original Authors: Microsoft Corporation and the Azure team
Original License: MIT License
Original Focus: Azure SQL Database with Azure AD authentication
Key Enhancement
This fork extends the original Azure-only MCP server to support local SQL Server databases with username/password authentication, making it accessible for:
🏠 Local Development: Connect to local SQL Server instances
🏢 On-Premises Deployments: Support enterprise SQL Server installations
🔄 Hybrid Environments: Seamlessly switch between local and Azure databases
🚀 Broader Accessibility: Remove Azure dependency for local development
What We Added
Feature | Original Repository | This Fork |
Azure SQL Database | ✅ Azure AD only | ✅ Azure AD support |
Local SQL Server | ❌ Not supported | ✅ Username/password auth |
Authentication Methods | 1 (Azure AD) | 3 (Azure AD, SQL Server, Windows) |
Target Audience | Azure users only | Local + Azure + On-premises |
Development Setup | Requires Azure account | Works with local SQL Server |
Acknowledgments
We are deeply grateful to Microsoft and the Azure team for creating the foundational architecture, security implementation, and tool design that made this enhanced version possible.
This enhanced version would not exist without their excellent foundational work.
License: MIT License - see LICENSE file for details.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI assistants to interact with both local SQL Server and Azure SQL Database through natural language, supporting queries, data manipulation, and schema operations with built-in security features.