MSSql
The MSSQL MCP Server allows your AI assistants (MCP clients) to directly access to Microsoft SQL Server databases.
It built with Akka.NET for internal coordination and the official MCP C# SDK for protocol compliance.
Features
- 🗃️ Schema Discovery – AI agents can explore database structure without complex SQL queries
- ⚡ Full SQL Support – Execute SELECT, INSERT, UPDATE, DELETE, and DDL operations
- ✅ Connection Validation – Automatic database connectivity checks on startup
- 🛡️ Comprehensive Error Handling – Clear, actionable error messages for troubleshooting
- 📊 Table Formatting – Query results formatted in readable tables for AI consumption
- 🐳 Docker Support – Easy deployment with built-in .NET Docker tooling
- 🏗️ Akka.NET Architecture – Reliable internal coordination and state management
Use Cases
- Database Documentation Generation – AI agents can automatically discover and document database schemas, table relationships, and data structures without manual SQL scripting
- Automated Data Quality Checks – Enable AI to run validation queries, identify data inconsistencies, and generate reports on database health and integrity issues
- Dynamic Query Building – Allow AI assistants to construct and execute complex SQL queries based on natural language requests, perfect for non-technical users who need database insights
- Database Migration Assistance – AI agents can analyze existing schemas, suggest optimizations, and help plan database migrations by understanding current structure and data patterns
Configuration
The server requires one environment variable:
MSSQL_CONNECTION_STRING – Your complete SQL Server connection string
Connection String Examples:
Windows Authentication:
Server=localhost;Database=MyDatabase;Trusted_Connection=true;SQL Server Authentication:
Server=localhost;Database=MyDatabase;User Id=myuser;Password=mypassword;Azure SQL Database:
Server=myserver.database.windows.net;Database=mydatabase;User Id=myuser;Password=mypassword;Encrypt=true;MCP Client Configuration
Cursor:
Add to Cursor Settings → Features → Model Context Protocol:
{
"mcpServers": {
"mssql": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MSSQL_CONNECTION_STRING",
"mssql-mcp:latest"
],
"env": {
"MSSQL_CONNECTION_STRING": "Server=host.docker.internal,1533; Database=MyDb; User Id=myUser; Password=My(!)Password;TrustServerCertificate=true;"
}
}
}
}Claude Desktop:
Add to configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mssql": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MSSQL_CONNECTION_STRING",
"mssql-mcp:latest"
],
"env": {
"MSSQL_CONNECTION_STRING": "Server=host.docker.internal,1533; Database=MyDb; User Id=myUser; Password=My(!)Password;TrustServerCertificate=true;"
}
}
}
}Available Tools
- execute_sql – Execute any SQL query against the database
- list_tables – List all tables with schema, name, type, and row count
- list_schemas – List all available schemas/databases in the SQL Server instance
Docker Networking Solutions
For SQL Server on Host Machine: Use host.docker.internal instead of localhost in connection strings.
For SQL Server in Docker: Create a Docker Compose setup with custom networks:
version: '3.8'
networks:
sql-network:
driver: bridge
services:
mssql-mcp:
build: .
environment:
- MSSQL_CONNECTION_STRING=Server=sqlserver;Database=MyDatabase;User Id=sa;Password=YourPassword123!;
networks:
- sql-network
depends_on:
- sqlserver
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=YourPassword123!
networks:
- sql-networkFor Linux: Use host network mode:
docker run -it --rm --network host \
-e MSSQL_CONNECTION_STRING="Server=localhost;Database=MyDB;User Id=sa;Password=YourPassword123!;" \
mssql-mcp:latestSecurity Best Practices
Create dedicated database users with minimal permissions:
Read-only access:
CREATE LOGIN mcp_readonly WITH PASSWORD = 'SecurePassword123!';
CREATE USER mcp_readonly FOR LOGIN mcp_readonly;
GRANT SELECT ON SCHEMA::dbo TO mcp_readonly;
GRANT VIEW DEFINITION ON SCHEMA::dbo TO mcp_readonly;Read-write access:
CREATE LOGIN mcp_readwrite WITH PASSWORD = 'SecurePassword123!';
CREATE USER mcp_readwrite FOR LOGIN mcp_readwrite;
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO mcp_readwrite;
GRANT VIEW DEFINITION ON SCHEMA::dbo TO mcp_readwrite;FAQs
Q: Can I connect to Azure SQL Database?
A: Yes, use a connection string with Encrypt=true parameter. The server supports all SQL Server variants including Azure SQL Database, SQL Managed Instance, and on-premises installations.
Q: How do I troubleshoot connection issues?
A: First, test your connection string with SQL Server Management Studio. For Docker deployments, use host.docker.internal instead of localhost. Check that TCP/IP is enabled in SQL Server Configuration Manager and port 1433 is accessible.
Q: Is this safe for production use?
A: The server itself is production-ready, but security depends on your configuration. Create dedicated database users with minimal required permissions, use encrypted connections, and implement proper access controls. Never use sa or admin accounts.
Q: Can I run this without Docker?
A: Yes, you can run the compiled binary directly. You’ll need .NET 9.0 runtime installed. Use the local binary configuration in your MCP client settings instead of Docker commands.
Q: How do I handle special characters in connection strings?
A: Escape special characters in passwords and use proper JSON encoding in configuration files. For Docker environment variables, consider using Docker secrets or external configuration files for complex passwords.
Latest MCP Servers
CVE
WebMCP
webmcp is an MCP server that connects MCP clients to web search, page fetching, and local LLM-based extraction. It’s ideal…
Google Meta Ads GA4
Featured MCP Servers
Notion
Claude Peers
Excalidraw
FAQs
Q: What exactly is the Model Context Protocol (MCP)?
A: MCP is an open standard, like a common language, that lets AI applications (clients) and external data sources or tools (servers) talk to each other. It helps AI models get the context (data, instructions, tools) they need from outside systems to give more accurate and relevant responses. Think of it as a universal adapter for AI connections.
Q: How is MCP different from OpenAI's function calling or plugins?
A: While OpenAI's tools allow models to use specific external functions, MCP is a broader, open standard. It covers not just tool use, but also providing structured data (Resources) and instruction templates (Prompts) as context. Being an open standard means it's not tied to one company's models or platform. OpenAI has even started adopting MCP in its Agents SDK.
Q: Can I use MCP with frameworks like LangChain?
A: Yes, MCP is designed to complement frameworks like LangChain or LlamaIndex. Instead of relying solely on custom connectors within these frameworks, you can use MCP as a standardized bridge to connect to various tools and data sources. There's potential for interoperability, like converting MCP tools into LangChain tools.
Q: Why was MCP created? What problem does it solve?
A: It was created because large language models often lack real-time information and connecting them to external data/tools required custom, complex integrations for each pair. MCP solves this by providing a standard way to connect, reducing development time, complexity, and cost, and enabling better interoperability between different AI models and tools.
Q: Is MCP secure? What are the main risks?
A: Security is a major consideration. While MCP includes principles like user consent and control, risks exist. These include potential server compromises leading to token theft, indirect prompt injection attacks, excessive permissions, context data leakage, session hijacking, and vulnerabilities in server implementations. Implementing robust security measures like OAuth 2.1, TLS, strict permissions, and monitoring is crucial.
Q: Who is behind MCP?
A: MCP was initially developed and open-sourced by Anthropic. However, it's an open standard with active contributions from the community, including companies like Microsoft and VMware Tanzu who maintain official SDKs.



