Get the FREE Ultimate OpenClaw Setup Guide →

mssqlclient

A Microsoft SQL Server client implementing the Model Context Protocol (MCP). This server provides SQL query capabilities through a simple MCP interface.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio aadversteeg-mssqlclient-mcp-server dotnet tool exec -y ave.mcpserver.mssqlclient \
  --env MSSQL_CONNECTIONSTRING="Data Source=localhost;Database=your_db;User Id=your_user;Password=your_password;TrustServerCertificate=True;"

How to use

This MCP server implements a comprehensive SQL Server client that exposes the MCP tools for interacting with SQL Server databases. It supports both database-scoped operations (when a Database parameter is present in the connection string) and server-scoped operations (when no database is specified). Core capabilities include executing SQL queries, listing tables with schema and row counts, retrieving detailed table schemas, and managing plus executing stored procedures with rich metadata support. Additionally, it provides parameter discovery in JSON Schema format, type-safe execution with automatic JSON-to-SQL conversion, cross-database procedure execution in server mode, and timing/profiling data to help optimize queries.

To use the tools, configure the MCP server in your Claude Desktop / Claude Code setup under mcpServers. By default, only read-only operations are enabled (such as listing tables, viewing schemas, and listing stored procedures). To enable execution tools like execute_query and execute_stored_procedure, set the appropriate DatabaseConfiguration__Enable* environment variables to "true" in your configuration (these are disabled by default for security): EnableExecuteQuery, EnableExecuteStoredProcedure, EnableStartQuery, and EnableStartStoredProcedure. Once enabled, you can invoke query execution, stored procedure execution, and create sessions for long-running operations, all within the MCP interface.

The server also includes advanced features such as JSON Schema output for parameter metadata, case-insensitive parameter handling with @ prefixes, and robust error handling. Its two-mode architecture supports both single-database and multi-database scenarios, and you can monitor execution timing and provide per-operation timeouts to suit your deployment needs.

How to install

Prerequisites:

  • .NET 10.0 SDK
  • Docker (optional for container deployment)

Install from source:

  1. Clone the repository: git clone https://github.com/aadversteeg/mssqlclient-mcp-server.git

  2. Navigate to the source directory: cd mssqlclient-mcp-server/src

  3. Build the project: dotnet build

  4. Run unit tests (optional): dotnet test

Running in Docker (optional):

  1. Build the Docker image as described in the Docker instructions, or pull the prebuilt image from Docker Hub.
  2. Run the container with a connection string in an environment variable, for example: docker run -d --name mssql-mcp -e "MSSQL_CONNECTIONSTRING=Server=your_server;Database=your_db;User Id=your_user;Password=your_password;TrustServerCertificate=True;" mssqlclient-mcp-server:latest

Using the .NET tool (recommended for local development):

  1. Install the global tool: dotnet tool install --global Ave.McpServer.MsSqlClient
  2. Run the server: ave-mcpserver-mssqlclient
  3. Or run via tool exec (one-shot, without permanent installation): dotnet tool exec -y ave.mcpserver.mssqlclient

Configuring Claude Desktop / Claude Code:

  • Add the server under mcpServers with the appropriate environment variables to enable/disable features as needed (see Configuring Claude Desktop / Claude Code in the README for details).

Additional notes

Security note: Query and stored procedure execution can be disabled by default and must be explicitly enabled via environment variables. The breaking change introduced in 0.0.5 requires you to set DatabaseConfiguration__EnableExecuteQuery, DatabaseConfiguration__EnableExecuteStoredProcedure, DatabaseConfiguration__EnableStartQuery, and DatabaseConfiguration__EnableStartStoredProcedure to true if you rely on those capabilities. Ensure your MSSQL_CONNECTIONSTRING is kept secret and never exposed in client-side configurations. For container deployments, pass the connection string via environment variables and review container logs for any authentication or network issues. If you encounter schema or metadata issues, verify that the connected SQL Server user has appropriate permissions for the requested operations and that the server mode vs database mode behavior aligns with your connection string (presence of Database= in the connection string).

Environment variables to consider:

  • MSSQL_CONNECTIONSTRING: full ADO.NET connection string to SQL Server
  • DatabaseConfiguration__EnableExecuteQuery: true to enable execute_query tools
  • DatabaseConfiguration__EnableExecuteStoredProcedure: true to enable execute_stored_procedure tools
  • DatabaseConfiguration__EnableStartQuery: true to enable start_query session tools
  • DatabaseConfiguration__EnableStartStoredProcedure: true to enable start_stored_procedure session tools

Related MCP Servers

Sponsor this space

Reach thousands of developers