MSSQL Database MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MSSQL Database MCP Server show me all customers from New York"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MSSQL Database MCP Server
Note: This repository is based on the Azure SQL-AI-samples MssqlMcp project with additional enhancements and security improvements.
β οΈ EXPERIMENTAL USE ONLY - This MCP Server is provided as an example for educational and experimental purposes only. It is NOT intended for production use. Please use appropriate security measures and thoroughly test before considering any kind of deployment.
What is this? π€
This is a server that lets your LLMs (like Claude) talk directly to your MSSQL Database data! Think of it as a friendly translator that sits between your AI assistant and your database, making sure they can chat securely and efficiently.
Quick Example
You: "Show me all customers from New York"
Claude: *queries your MSSQL Database database and gives you the answer in plain English*Related MCP server: DB Analyzer MCP Server
How Does It Work? π οΈ
This server leverages the Model Context Protocol (MCP), a versatile framework that acts as a universal translator between AI models and databases. It supports multiple AI assistants including Claude Desktop and VS Code Agent.
What Can It Do? π
Run MSSQL Database queries by just asking questions in plain English
Create, read, update, and delete data
Manage database schema (tables, indexes)
Secure connection handling
Real-time data interaction
Quick Start π
Prerequisites
Node.js 14 or higher
Claude Desktop or VS Code with Agent extension
Additional Prerequisites for Kerberos Ticket Authentication (macOS/Linux)
If you want to use cached Kerberos tickets (via kinit) instead of storing credentials in configuration:
Install Microsoft ODBC Driver 18 for SQL Server
macOS (via Homebrew):
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update brew install msodbcsql18Linux: See Microsoft's ODBC Driver documentation
Install Native Node.js Driver
npm install msnodesqlv8Obtain Kerberos Ticket
kinit your-username@YOUR.DOMAIN.COM klist # Verify ticket
Note: If you don't need Kerberos ticket support, you can skip these steps and use credentials directly in the configuration (see Kerberos Authentication section below).
Set up project
Install Dependencies
Run the following command in the root folder to install all necessary dependencies:npm installBuild the Project
Compile the project by running:npm run build
Configuration Setup
Option 1: VS Code Agent Setup
Install VS Code Agent Extension
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search for "Agent" and install the official Agent extension
Create MCP Configuration File
Create a
.vscode/mcp.jsonfile in your workspaceAdd the following configuration:
{ "servers": { "mssql-nodejs": { "type": "stdio", "command": "node", "args": ["q:\\Repos\\SQL-AI-samples\\MssqlMcp\\Node\\dist\\index.js"], "env": { "SERVER_NAME": "your-server-name.database.windows.net", "DATABASE_NAME": "your-database-name", "READONLY": "false" } } } }Alternative: User Settings Configuration
Open VS Code Settings (Ctrl+,)
Search for "mcp"
Click "Edit in settings.json"
Add the following configuration:
{ "mcp": { "servers": { "mssql": { "command": "node", "args": ["C:/path/to/your/Node/dist/index.js"], "env": { "SERVER_NAME": "your-server-name.database.windows.net", "DATABASE_NAME": "your-database-name", "READONLY": "false" } } } } }Restart VS Code
Close and reopen VS Code for the changes to take effect
Verify MCP Server
Open Command Palette (Ctrl+Shift+P)
Run "MCP: List Servers" to verify your server is configured
You should see "mssql" in the list of available servers
Option 2: Claude Desktop Setup
Open Claude Desktop Settings
Navigate to File β Settings β Developer β Edit Config
Open the
claude_desktop_configfile
Add MCP Server Configuration Replace the content with the configuration below, updating the path and credentials:
{ "mcpServers": { "mssql": { "command": "node", "args": ["C:/path/to/your/Node/dist/index.js"], "env": { "SERVER_NAME": "your-server-name.database.windows.net", "DATABASE_NAME": "your-database-name", "READONLY": "false" } } } }Restart Claude Desktop
Close and reopen Claude Desktop for the changes to take effect
Configuration Parameters
SERVER_NAME: Your SQL Server name
For Azure SQL:
my-server.database.windows.netFor local SQL Server:
localhostor.\SQLEXPRESSor(local)or server IPFor non-standard port: Use
hostname,portformat (e.g.,sqlserver.domain.com,50000)Default port is 1433, specify if different
DATABASE_NAME: Your database name
READONLY: Set to
"true"to restrict to read-only operations,"false"for full accessAUTH_METHOD: Authentication method (defaults to
"default"):"default"- DefaultAzureCredential (for Azure SQL, recommended for production)"interactive"- InteractiveBrowserCredential (for Azure SQL, opens browser)"integrated"- Windows Integrated Authentication (Windows only, uses current user)"kerberos"- Kerberos Authentication (works on Windows, Linux, macOS with domain setup)"sql"- SQL Server Authentication with username/password
CONNECTION_TIMEOUT: (Optional) Connection timeout in seconds. Defaults to
30if not set.TRUST_SERVER_CERTIFICATE: (Optional) Set to
"true"to trust self-signed server certificates. Defaults to"false".Path: Update the path in
argsto point to your actual project location.
Additional Parameters for SQL Server Authentication (AUTH_METHOD="sql"):
SQL_USER: SQL Server username
SQL_PASSWORD: SQL Server password
Additional Parameters for Kerberos Authentication (AUTH_METHOD="kerberos"):
Kerberos authentication supports two modes:
Mode 1: With Domain Credentials (works everywhere)
DOMAIN: Windows/Active Directory domain (e.g., "ELON", "MYDOMAIN")
USERNAME: Domain username (without domain prefix)
PASSWORD: Domain password
Uses NTLM authentication - works on Windows, macOS, and Linux
Mode 2: With Cached Kerberos Ticket (macOS/Linux only)
Requires Microsoft ODBC Driver 18 and msnodesqlv8 package (see Prerequisites above)
Obtains authentication from cached Kerberos ticket (via
kinit)Do not provide DOMAIN, USERNAME, or PASSWORD parameters
More secure - no passwords stored in configuration
Run
kinit username@DOMAIN.COMbefore starting the MCP server
Sample Configurations
You can find sample configuration files in the src/samples/ folder:
claude_desktop_config.json- For Claude Desktopvscode_agent_config.json- For VS Code Agent
Example: Local SQL Server with Windows Integrated Authentication
Note: Windows Integrated Authentication only works on Windows.
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"mssql": {
"command": "node",
"args": ["C:/path/to/your/dist/index.js"],
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "integrated",
"TRUST_SERVER_CERTIFICATE": "true",
"READONLY": "false"
}
}
}
}VS Code (.vscode/mcp.json):
{
"servers": {
"mssql": {
"type": "stdio",
"command": "node",
"args": ["/path/to/your/dist/index.js"],
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "integrated",
"TRUST_SERVER_CERTIFICATE": "true",
"READONLY": "false"
}
}
}
}Example: Kerberos Authentication (Cross-Platform)
Mode 1: With Domain Credentials (NTLM)
Works on all platforms without additional setup:
{
"env": {
"SERVER_NAME": "sqlserver.mydomain.com,50000",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "kerberos",
"DOMAIN": "MYDOMAIN",
"USERNAME": "myuser",
"PASSWORD": "MyPassword123!",
"TRUST_SERVER_CERTIFICATE": "false",
"READONLY": "false"
}
}Mode 2: With Cached Kerberos Ticket (macOS/Linux)
Requires ODBC Driver 18 and msnodesqlv8 (see Prerequisites above).
First, obtain a Kerberos ticket:
kinit myuser@MYDOMAIN.COM
klist # Verify ticket is validThen configure without credentials:
{
"env": {
"SERVER_NAME": "sqlserver.mydomain.com,50000",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "kerberos",
"TRUST_SERVER_CERTIFICATE": "false",
"READONLY": "false"
}
}Note: Remember to restart Claude Desktop or VS Code after updating the configuration.
Example: Local SQL Server with SQL Authentication
{
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "sql",
"SQL_USER": "sa",
"SQL_PASSWORD": "YourPassword123!",
"TRUST_SERVER_CERTIFICATE": "true",
"READONLY": "false"
}
}Example: Azure SQL Database
{
"env": {
"SERVER_NAME": "myserver.database.windows.net",
"DATABASE_NAME": "MyDatabase",
"AUTH_METHOD": "default",
"READONLY": "false"
}
}Usage Examples
Once configured, you can interact with your database using natural language:
"Show me all users from New York"
"Create a new table called products with columns for id, name, and price"
"Update all pending orders to completed status"
"List all tables in the database"
"Describe the schema of the users table"
Schema Support
All tools now support optional schema names (defaults to 'dbo' if not specified):
"Create a table called products in the sales schema"
"List all tables in the dbo schema"
"Drop the temp_data table from the staging schema"
"Describe the customers table in the sales schema"
This allows you to work with multi-schema databases more effectively.
Security Notes
All SQL identifiers (table names, column names, schema names) are validated and escaped to prevent SQL injection
The server requires a WHERE clause for read operations to prevent accidental full table scans
Update operations require explicit WHERE clauses for security
Set
READONLY: "true"in environments if you only need read accessCharacter and data type validation prevents malicious input
Token refresh includes 5-minute buffer to prevent expiration during long queries (Azure SQL)
Use
AUTH_METHOD="default"(DefaultAzureCredential) for production Azure environments for better security
Authentication Methods
For Azure SQL Database:
DefaultAzureCredential (recommended): Automatically uses managed identity, environment variables, or Azure CLI credentials
InteractiveBrowserCredential: Opens a browser for interactive login, useful for development
For Local SQL Server:
Windows Integrated Authentication (
AUTH_METHOD="integrated"): Uses current Windows user credentials (Windows only)Kerberos Authentication (
AUTH_METHOD="kerberos"): Uses domain credentials with NTLM or cached Kerberos ticket (cross-platform)SQL Server Authentication (
AUTH_METHOD="sql"): Traditional username/password authentication
Important Security Notes:
Never commit passwords or connection strings to source control
For local SQL Server, Integrated or Kerberos Authentication is more secure than SQL Authentication
For cross-platform domain authentication, use Kerberos with cached tickets (
kiniton Linux/macOS)Use
TRUST_SERVER_CERTIFICATE="true"only for development/testing with self-signed certificatesConsider using
READONLY="true"when querying production databases
Troubleshooting
Connection Issues
"Cannot resolve hostname" or "Connection timeout":
For on-premises SQL Servers, ensure you're connected to the correct network (VPN if required)
Verify the server name and port are correct (use
hostname,portformat for non-standard ports)Check that the SQL Server is configured to accept remote connections
Verify firewall rules allow connections on the SQL Server port (default: 1433)
Test connectivity with:
telnet hostname portornc -zv hostname port
"Login failed" or "Authentication failed":
For Kerberos authentication, ensure you've obtained a valid ticket with
kinit username@DOMAIN.COMVerify you have the correct credentials and permissions on the target database
Check that the authentication method matches your SQL Server configuration
For Windows Integrated Authentication, ensure you're running on Windows
"Trust server certificate" errors:
For development/testing with self-signed certificates, set
TRUST_SERVER_CERTIFICATE="true"For production, ensure proper SSL certificates are configured on the SQL Server
MCP Protocol JSON parsing errors:
If you see "Unexpected token" errors, ensure you're using the latest version (console.log fixed)
Restart Claude Desktop or VS Code after updating the MCP server configuration
You should now have successfully configured the MCP server for MSSQL Database with your preferred AI assistant. This setup allows you to seamlessly interact with MSSQL Database through natural language queries!
Available Tools
3 toolsdescribe_tableA
Describes the schema (columns and types) of a specified MSSQL Database table. Optionally specify a schema name (defaults to 'dbo').
Inputs: tableName (required), schemaName.
list_tableA
Lists tables in an MSSQL Database, or list tables in specific schemas. Returns fully qualified table names (schema.table).
Inputs: parameters.
read_dataA
Executes a SELECT query on an MSSQL Database table. The query must start with SELECT and cannot contain any destructive SQL operations for security reasons.
Inputs: query (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: listing tables, reading data, and describing table schema. There is no overlap between them and an agent can easily select the right one.
Names follow a consistent verb_noun pattern (list_table, read_data, describe_table). Slight inconsistency as read_data operates on rows while the others target tables, but the convention is readable and predictable.
Three tools is functional but thin for a database serverβno write operations, connection/schema listing, or query execution beyond SELECT. It sits at the borderline of feeling undersized for the stated purpose.
The surface only covers read-only introspection and SELECT data access, with no insert/update/delete, no schema listing tool, and no way to run arbitrary queries or inspect indexes/constraints. This is a significant gap if the server is meant to support broader MSSQL workflows.
Maintenance
Related MCP Connectors
Query, explore, and manage your databases through natural conversation.
Ask questions in plain language, get answers from your business database. No SQL required.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with SQL Server databases through natural language, providing capabilities for executing queries, exploring schemas, analyzing performance, backing up tables, and managing data with built-in safety limits.-
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze and query SQL Server databases, including schema discovery, health checks, and data retrieval.10-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with MSSQL databases through natural language, supporting CRUD operations and schema management.MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI clients to interact with Microsoft SQL Server databases through natural language, translating prompts into structured queries and returning clean results for AI-powered data access.-