MSSQL MCP Server
The MSSQL MCP Server enables natural language interaction with Microsoft SQL Server databases through LLMs like Claude, facilitating comprehensive data manipulation and schema management.
Query Data: Execute SELECT queries to retrieve data from tables
Insert Data: Add single or multiple records to database tables
Update Data: Modify existing table data with mandatory WHERE clause for security
Create Tables: Define new tables with custom columns and data types
Drop Tables: Remove entire tables from the database
Create Indexes: Add indexes on columns for improved query performance
Describe Tables: Retrieve schema information including columns and data types
List Tables: View all available tables, with optional schema filtering
Secure Connections: Handle database connections securely with optional read-only mode
Enables querying, reading, and modifying Microsoft SQL Server databases (part of the .NET ecosystem) through natural language, including executing SQL operations, managing tables and indexes, and performing CRUD operations on data.
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 MCP Server show me the top 10 customers by total order amount"
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 MCP Server
A Model Context Protocol (MCP) server that enables LLMs like Claude to interact with Microsoft SQL Server databases through natural language.
Features
🔍 Query your SQL Server database using natural language
📊 Read, insert, update, and delete data
🏗️ Create and manage tables and indexes
🔒 Secure connection handling with optional read-only mode
⚡ Direct TypeScript execution with tsx - no build step required
Related MCP server: ExecuteAutomation Database Server
Quick Start
Option 1: Use directly from GitHub with npx (Recommended)
No installation needed! Just configure Claude Desktop:
Windows
Add to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"mssql": {
"type": "stdio",
"command": "cmd",
"args": ["/c", "npx", "-y", "github:EvilPhatBoi/McpSqlServer"],
"env": {
"SERVER_NAME": "your-server.database.windows.net",
"DATABASE_NAME": "your-database",
"SQL_USERNAME": "your-username",
"SQL_PASSWORD": "your-password",
"PORT": "1433",
"ENCRYPT": "true",
"TRUST_SERVER_CERTIFICATE": "false",
"CONNECTION_TIMEOUT": "30",
"READONLY": "false"
}
}
}
}macOS/Linux
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"mssql": {
"type": "stdio",
"command": "npx",
"args": ["-y", "github:EvilPhatBoi/McpSqlServer"],
"env": {
"SERVER_NAME": "your-server.database.windows.net",
"DATABASE_NAME": "your-database",
"SQL_USERNAME": "your-username",
"SQL_PASSWORD": "your-password",
"PORT": "1433",
"ENCRYPT": "true",
"TRUST_SERVER_CERTIFICATE": "false",
"CONNECTION_TIMEOUT": "30",
"READONLY": "false",
"DEBUG": "false"
}
}
}
}Note for legacy SQL Servers: If you experience SSL/TLS connection issues with older SQL Server versions, try:
"ENCRYPT": "false"to disable TLS/SSL encryption"TRUST_SERVER_CERTIFICATE": "true"to trust self-signed certificates"CONNECTION_TIMEOUT": "60"or higher for slower connections"DEBUG": "true"to see detailed connection logs
Option 2: Clone and run locally
Clone the repository:
git clone https://github.com/EvilPhatBoi/McpSqlServer.git
cd McpSqlServerInstall dependencies:
npm installCreate
.envfile:
cp .env.example .env
# Edit .env with your database credentialsConfigure Claude Desktop to point to your local installation:
{
"mcpServers": {
"mssql": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "C:/path/to/McpSqlServer/src/index.ts"],
"env": {
"SERVER_NAME": "your-server.database.windows.net",
"DATABASE_NAME": "your-database",
"SQL_USERNAME": "your-username",
"SQL_PASSWORD": "your-password"
}
}
}
}Environment Variables
Variable | Description | Default |
| SQL Server hostname | Required |
| Database name | Required |
| SQL username | Required |
| SQL password | Required |
| SQL Server port |
|
| Enable TLS/SSL encryption |
|
| Trust self-signed certificates |
|
| Connection timeout in seconds |
|
| Enable read-only mode |
|
| Enable debug logging |
|
Usage Examples
Once configured, you can interact with your database using natural language in Claude:
"Show me all customers from New York"
"Create a table called products with columns for id, name, and price"
"Update the price of product with id 5 to 29.99"
"List all tables in the database"
"Describe the structure of the orders table"
Development
Running locally with tsx:
npm run start # Run the server
npm run dev # Run with watch modeType checking:
npm run typecheckSecurity Notes
Never commit
.envfiles with real credentialsUse read-only mode (
READONLY=true) in production for safetyThe server requires WHERE clauses for updates to prevent accidental mass updates
Consider using environment-specific credentials
Troubleshooting
Connection issues
Ensure your SQL Server allows remote connections
Check firewall rules for SQL Server port (default 1433, or your custom PORT setting)
Verify credentials and server name
Enable debug logging by setting
DEBUG=truein your environment variables
SSL/TLS connection issues
For older SQL Server versions that don't support modern TLS, set
ENCRYPT=falseIf using self-signed certificates, set
TRUST_SERVER_CERTIFICATE=trueFor connection timeout issues, increase
CONNECTION_TIMEOUTto 60 or higherCheck that your SQL Server accepts the TLS version your Node.js supports
Debug mode
To enable detailed logging for troubleshooting:
"env": {
"DEBUG": "true",
// ... other environment variables
}Authentication errors
This server uses SQL authentication, not Windows authentication
Ensure SQL authentication is enabled on your server
Check that the SQL user has appropriate permissions
License
MIT
Available Tools
8 toolscreate_indexC
Creates an index on a specified column or columns in an MSSQL Database table
Inputs: tableName (required), indexName (required), columns (required), schemaName, +2 more.
create_tableC
Creates a new table in the MSSQL Database with the specified columns.
Inputs: tableName (required), columns (required).
describe_tableA
Describes the schema (columns and types) of a specified MSSQL Database table.
Inputs: tableName (required).
drop_tableC
Drops a table from the MSSQL Database.
Inputs: tableName (required).
insert_dataA
Inserts data into an MSSQL Database table. Supports both single record insertion and multiple record insertion using standard SQL INSERT with VALUES clause. FORMAT EXAMPLES: Single Record Insert: { "tableName": "Users", "data": { "name": "John Doe", "email": "john@example.com", "age": 30, "isActive": true, "createdDate": "2023-01-15" } } Multiple Records Insert: { "tableName": "Users", "data": [ { "name": "John Doe", "email": "john@example.com", "age": 30, "isActive": true, "createdDate": "2023-01-15" }, { "name": "Jane Smith", "email": "jane@example.com", "age": 25, "isActive": false, "createdDate": "2023-01-16" } ] } GENERATED SQL FORMAT:
Single: INSERT INTO table (col1, col2) VALUES (@param1, @param2)
Multiple: INSERT INTO table (col1, col2) VALUES (@param1, @param2), (@param3, @param4), ... IMPORTANT RULES:
For single record: Use a single object for the 'data' field
For multiple records: Use an array of objects for the 'data' field
All objects in array must have identical column names
Column names must match the actual database table columns exactly
Values should match the expected data types (string, number, boolean, date)
Use proper date format for date columns (YYYY-MM-DD or ISO format)
Inputs: tableName (required), data (required).
list_tableC
Lists tables in an MSSQL Database, or list tables in specific schemas
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).
update_dataB
Updates data in an MSSQL Database table using a WHERE clause. The WHERE clause must be provided for security.
Inputs: tableName (required), updates (required), whereClause (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose with no ambiguity. create_index, create_table, describe_table, drop_table, insert_data, list_table, read_data, and update_data each target specific database operations with no overlap in functionality. The descriptions clearly differentiate between schema operations, data manipulation, and querying.
All tools follow a consistent verb_noun pattern with snake_case throughout. The naming convention is perfectly uniform: create_index, create_table, describe_table, drop_table, insert_data, list_table, read_data, and update_data all maintain the same structure and style.
With 8 tools, this server is well-scoped for MSSQL database operations. Each tool earns its place by covering essential database tasks: schema management (create/drop/describe/list tables, create index) and data operations (insert/read/update). The count is appropriate for the domain without being overwhelming.
The tool surface covers most essential MSSQL operations well, including table lifecycle management and core CRUD operations. However, there are minor gaps: no delete_data tool (only update_data with WHERE clause), no transaction management tools, and no stored procedure or view operations. Agents can work around these gaps using existing tools.
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseBqualityBmaintenanceA Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.1404MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs like Claude to interact with SQLite and SQL Server databases, allowing for schema inspection and SQL query execution.782 npm391MIT
- FlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.-
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants (Cursor, Windsurf, Claude Code) to interact with Microsoft SQL Server databases by providing connectivity through environment-configurable connections.8601 npm8MIT