mcp-server-mssql
Click on "Install 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., "@mcp-server-mssqlshow me the structure of the products table"
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 for Microsoft SQL Server databases, providing secure database operations through a standardized interface.
Note: This project was created from the Azure SQL AI Samples repository, specifically the
MssqlMcp/Nodeimplementation. The upstream sample was removed from that repository in June 2026 (PR #96, "Removed unsafe MCP sample"); this fork includes all upstream changes through the final version (Nov 2025), including theSELECT ... INTOsecurity fix.
Features
Secure Database Operations: Execute SELECT queries with comprehensive security validation
Table Management: List, describe, and manage database tables and indexes
Data Manipulation: Insert, update, and query data with proper validation
Read-Only Mode: Optional read-only mode for enhanced security
Connection Pooling: Efficient database connection management with retry logic
SQL Injection Protection: Advanced security measures to prevent malicious queries
Related MCP server: Microsoft SQL Server MCP Server
Available Tools
Read Operations (Always Available)
list_table- List tables in the database, optionally filtered by schemaread_data- Execute SELECT queries with security validationdescribe_table- Get table schema informationdescribe_index- Get index information for tables
Write Operations (Requires READONLY=false)
insert_data- Insert data into tablesupdate_data- Update existing recordscreate_table- Create new tablescreate_index- Create indexes on tablesdrop_table- Drop tables (use with caution)
Installation
Clone this repository:
git clone <repository-url>
cd mcp-server-mssqlInstall dependencies:
npm installBuild the project:
npm run buildConfiguration
Environment Variables
The server supports both individual environment variables and a DATABASE_URL format:
Option 1: Individual Variables
SERVER_NAME=your-server.database.windows.net
DATABASE_NAME=your-database
SQL_USER=your-username
SQL_PASSWORD=your-password
READONLY=true
TRUST_SERVER_CERTIFICATE=true
CONNECTION_TIMEOUT=30Option 2: DATABASE_URL Format
DATABASE_URL=mssql://username:password@server:1433/database
READONLY=true
TRUST_SERVER_CERTIFICATE=trueConfiguration Parameters
Variable | Description | Default | Required |
| SQL Server hostname | - | Yes* |
| Database name | - | Yes* |
| Database username | - | Yes* |
| Database password | - | Yes* |
| Complete connection string | - | Yes* |
| Enable read-only mode |
| No |
| Trust server certificate |
| No |
| Connection timeout (seconds) |
| No |
| Prefix for tool names |
| No |
*Either individual variables or DATABASE_URL is required.
Usage
As an MCP Server
Configure the server in your MCP client (e.g., Claude Desktop, Cursor):
{
"mcpServers": {
"mssql-server": {
"command": "node",
"args": ["/path/to/mcp-server-mssql/dist/index.js"],
"env": {
"DATABASE_URL": "mssql://username:password@server:1433/database",
"READONLY": "true",
"TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}Example Configuration Files
See the included sample configurations:
sql-auth-config-example.json- Basic configuration examplesql-auth-config-individual.json- Individual environment variables example
Sample Configurations
Claude Desktop
{
"mcpServers": {
"mssql-sql-auth": {
"command": "node",
"args": ["/path/to/mcp-server-mssql/dist/index.js"],
"env": {
"DATABASE_URL": "mssql://your-username:your-password@your-server:1433/your-database",
"READONLY": "false",
"TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}Cursor
{
"mcpServers": {
"mssql-sql-auth": {
"command": "node",
"args": ["/path/to/mcp-server-mssql/dist/index.js"],
"env": {
"DATABASE_URL": "mssql://your-username:your-password@your-server:1433/your-database",
"READONLY": "false",
"TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}Security Features
Query Validation
Only SELECT queries are allowed in read operations
Comprehensive SQL injection protection
Dangerous keyword detection
Pattern-based malicious query detection
Query length limits
Connection Security
Encrypted connections by default
Configurable certificate trust
Connection pooling with timeout management
Automatic retry logic with exponential backoff
Read-Only Mode
When READONLY=true:
Only read operations are available
NOLOCK hints are automatically added to queries
Write operations are completely disabled
Development
Project Structure
src/
├── index.ts # Main server implementation
├── tools/ # Tool implementations
│ ├── CreateIndexTool.ts
│ ├── CreateTableTool.ts
│ ├── DescribeIndexTool.ts
│ ├── DescribeTableTool.ts
│ ├── DropTableTool.ts
│ ├── InsertDataTool.ts
│ ├── ListTableTool.ts
│ ├── ReadDataTool.ts
│ └── UpdateDataTool.ts
└── samples/ # Configuration examples
├── claude_desktop_config.json
├── cursor_desktop_config.json
└── vscode_agent_config.jsonBuilding
npm run buildDevelopment Mode
npm run watchTesting
npm startError Handling
The server provides comprehensive error handling:
Connection errors with retry logic
Query validation errors
Permission errors
Timeout handling
Graceful shutdown on process termination
Contributing
This project is based on the Azure SQL AI Samples repository. Contributions are welcome!
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Based on the Azure SQL AI Samples repository
Built with the Model Context Protocol SDK
Uses the mssql library for SQL Server connectivity
Support
For issues and questions:
Check the Azure SQL AI Samples repository for related issues
Create an issue in this repository
Review the Model Context Protocol documentation
Related Projects
Azure SQL AI Samples - Original source repository
Model Context Protocol - Protocol specification
MCP TypeScript SDK - SDK used in this project
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/acpepper/mcp-server-mssql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server