home / mcp / microsoft sql server
Provides MCP access to Microsoft SQL Server databases with multi-method authentication and SQL operations via Claude Desktop.
Configuration
View docs{
"mcpServers": {
"richardhan-mssql_mcp_server": {
"command": "uvx",
"args": [
"microsoft_sql_server_mcp"
],
"env": {
"MSSQL_PORT": "1433",
"MSSQL_USER": "your_username",
"MSSQL_SERVER": "localhost",
"MSSQL_ENCRYPT": "true",
"MSSQL_DATABASE": "your_database",
"MSSQL_PASSWORD": "your_password",
"MSSQL_WINDOWS_AUTH": "true"
}
}
}
}This MCP server enables secure access to Microsoft SQL Server databases via Claude Desktop. It exposes practical capabilities such as listing tables and running common SQL statements while supporting multiple authentication methods and flexible deployment options for local and cloud SQL instances.
You connect to the Microsoft SQL Server MCP Server through your MCP client (such as Claude Desktop) and start issuing database operations. Use the server to list tables in a database, execute queries (SELECT, INSERT, UPDATE, DELETE), and switch authentication strategies (SQL, Windows, or Azure AD) as your security and environment require. For Azure SQL Database, encryption is automatic and you can rely on the built-in protections. If you opt for Windows Authentication, your client will use your Windows credentials to access the database.
# Prerequisites: Python and/or Node tooling depending on your installation path
# 1) Install via Claude Desktop path (MCP config shown in the Quick Start)
```
```
# Quick path example shown for Claude Desktop integration
{
"mcpServers": {
"mssql": {
"command": "uvx",
"args": ["microsoft_sql_server_mcp"],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_DATABASE": "your_database",
"MSSQL_USER": "your_username",
"MSSQL_PASSWORD": "your_password"
}
}
}
}
```
```
# 2) Alternative installation with Python packaging
pip install microsoft_sql_server_mcp
```
```
# Then configureClaude Desktop to use the Python-based MCP server
{
"mcpServers": {
"mssql": {
"command": "python",
"args": ["-m", "microsoft_sql_server_mcp"],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_DATABASE": "your_database",
"MSSQL_USER": "your_username",
"MSSQL_PASSWORD": "your_password"
}
}
}
}
```
```
# 3) Development flow (optional for contributors)
git clone https://github.com/RichardHan/mssql_mcp_server.git
cd mssql_mcp_server
pip install -e .
```
Note: When you run the MCP server, ensure the environment variables reflect your database instance and credentials, and choose the method that matches your deployment (local via uvx or Python packaging).Basic authentication and connection details are provided as environment variables you pass to the MCP server. You can use either SQL authentication or Windows/Azure authentication depending on your environment.
# Basic SQL authentication
MSSQL_SERVER=localhost # Required
MSSQL_DATABASE=your_database # Required
MSSQL_USER=your_username # Required for SQL auth
MSSQL_PASSWORD=your_password # Required for SQL auth
```
```
# Windows authentication
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true # Use Windows credentials
```
```
# Azure SQL Database
MSSQL_SERVER=your-server.database.windows.net
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Encryption is automatic for Azure
```
```
# Optional settings
MSSQL_PORT=1433 # Custom port (default: 1433)
MSSQL_ENCRYPT=true # Force encryptionFollow these best practices to keep your SQL access secure: create a dedicated SQL user with minimal permissions (avoid admin/sa accounts), prefer Windows Authentication when possible, and enable encryption for sensitive data.
- Ensure the MCP server is configured with the correct server address, database name, and credentials for your environment. - If you switch authentication methods, adjust MSSQL_WINDOWS_AUTH or MSSQL_USER/MSSQL_PASSWORD accordingly. - When using Azure SQL Database, encryption is ensured automatically by the service.
- List tables and run a SELECT against your database via the MCP client. - Insert or update data using standard SQL statements through the same MCP interface.
- 🔍 List database tables - 📊 Execute SQL queries (SELECT, INSERT, UPDATE, DELETE) - 🔐 Multiple authentication methods (SQL, Windows, Azure AD) - 🏢 LocalDB and Azure SQL support - 🔌 Custom port configuration
Lists the tables available in the connected database.
Executes standard SQL statements such as SELECT, INSERT, UPDATE, DELETE against the connected database.
Supports multiple authentication methods: SQL, Windows, and Azure AD where applicable.