mssql
MSSQL Server MCP implementation written in C#
claude mcp add --transport stdio aaronontheweb-mssql-mcp docker 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;"
How to use
This MCP server provides AI agents with a dedicated interface to interact with a Microsoft SQL Server database. Through the available tools, you can discover database schemas, list tables and schemas, and execute arbitrary SQL queries directly from the MCP layer. The server uses a .NET-based implementation and Akka.NET for coordination, ensuring robust error handling and clean formatting of results for AI consumption. The primary tools exposed are: execute_sql to run any SQL statement, list_tables to retrieve table metadata including schema, name, type, and row count, and list_schemas to enumerate available schemas/databases in the SQL Server instance. To use it, connect via a Docker container (or your preferred deployment method) and supply a valid MSSQL_CONNECTION_STRING so the MCP server can authenticate against your database. The results are formatted into readable tables and error messages are actionable to help troubleshoot database access issues.
How to install
Prerequisites: Docker installed on your system, access to the network to pull the mssql-mcp Docker image, and a valid MSSQL server you can connect to.
- Install Docker:
- Windows: Docker Desktop
- macOS: Docker Desktop
- Linux: follow your distro's guide to install Docker Engine
- Pull and Run the MCP server via Docker:
# Run the MCP server container with your MSSQL connection string (example)
docker run -it --rm \
-e MSSQL_CONNECTION_STRING="Server=host.docker.internal,1533;Database=MyDb;User Id=myUser;Password=myPassword;TrustServerCertificate=true;" \
mssql-mcp:latest
- Alternatively, build your own image if you have a custom MSSQL setup:
# If you have a Dockerfile in the repo
git clone https://github.com/Aaronontheweb/mssql-mcp.git
cd mssql-mcp
# Build image locally
docker build -t mssql-mcp:local .
- Validate connectivity:
- Ensure MSSQL_CONNECTION_STRING is correct and that the SQL Server is reachable from your Docker host.
- Check container logs for startup messages and any connectivity errors.
- Optional: integrate with your MCP client (Cursor or Claude Desk-top) using the provided configuration examples in the README.
Additional notes
Notes and tips:
- Always supply a valid MSSQL_CONNECTION_STRING; incorrect credentials or network access will result in startup or runtime errors.
- If using Windows Authentication, ensure the connection string is formatted accordingly and that the container can reach the Windows-hosted SQL Server.
- When running in Docker, use host.docker.internal (or an appropriate host address) to reach a locally hosted SQL Server from inside the container.
- For production, consider enabling TLS/Encrypt in the connection string and managing secrets securely (do not hard-code credentials in your config).
- The MCP server supports standard SQL statements (SELECT/INSERT/UPDATE/DELETE) and DDL as needed by your agents; errors are surfaced with actionable messages for easier debugging.
- If you require multiple MCP servers, repeat the mcpServers entry with distinct names and separate connection strings.
Related MCP Servers
SharpToolsMCP
A suite of MCP tools for AIs to analyze and modify C# solutions with high signal, Roslyn powered context.
mobile-dev
This is a MCP designed to manage and interact with mobile devices and simulators.
Mcp.Net
A fully featured C# implementation of Anthropic's Model Context Protocol (MCP)
RimSearcher
A Model Context Protocol (MCP) server for fast searching and retrieval of RimWorld source code.
mcpapp-colorpicker
A Model Context Protocol (MCP) App built with .NET that provides an interactive color picker with a rich UI
RoslynMcpServer
Model Context Protocol server for Roslyn-powered C# refactoring operations