Get the FREE Ultimate OpenClaw Setup Guide →

mcp-ms-sql

A configurable Model Context Protocol (MCP) server for Microsoft SQL Server integration with Claude Code, supporting project-based database access with secure read/write operations.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio 0xhubed-mcp-ms-sql-server dotnet McpMsSqlServer.dll \
  --env MCP_CONFIG_NAME="my-project"

How to use

This MCP server provides a secure, project-based interface for interacting with Microsoft SQL Server databases via the Model Context Protocol. Each project configuration can enable or restrict read, write, and delete operations, enforce WHERE clauses for updates and deletes, and apply row limits, auditing, and schema restrictions. The server exposes a suite of tools for configuration management (list, switch, current configuration, test connections), core database operations (execute queries, retrieve schema info, insert/update/delete records with safeguards), and advanced features (build queries from natural language, analyze performance, discover data patterns, and profile data quality). Claude Desktop integration allows you to operate the MCP server using natural language prompts such as asking for table lists, inserting records, retrieving top products by sales, or updating records, all within the configured permission boundaries.

How to install

Prerequisites:

  • .NET 9.0 or later
  • Microsoft SQL Server (any supported version)
  • Claude Desktop (for Claude integration)
  • A machine with network access to the SQL Server instance

Installation steps:

  1. Clone the repository: git clone https://github.com/yourusername/mcp-ms-sql-server.git
  2. Navigate to the project folder: cd mcp-ms-sql-server
  3. Restore and build the project: dotnet restore dotnet build -c Release
  4. Create a project configuration file in the Configurations/ directory (as described in the README). Example: { "name": "My E-Commerce Project", "connectionString": "Server=localhost;Database=ECommerceDB;Integrated Security=true;", "allowedSchema": "dbo", "permissions": { "allowRead": true, "allowWrite": true, "allowDelete": false }, "security": { "requireWhereClause": true, "maxRowsPerQuery": 1000, "auditOperations": true } }
  5. Start the server (after a successful build): ./bin/Release/net9.0/McpMsSqlServer.exe // Alternatively, run via dotnet if using DLL directly: dotnet McpMsSqlServer.dll
  6. Configure Claude Desktop to point at the executable and set the MCP_CONFIG_NAME environment variable to your project name, as shown in the README example.

Additional notes

Tips and considerations:

  • Use dedicated database users with the minimum required permissions and enable audit logging for production configurations.
  • Always enforce a WHERE clause for UPDATE/DELETE operations and set row limits to prevent mass operations.
  • Store sensitive connection details in environment variables or secure vaults; avoid hard-coding credentials in configuration files.
  • When switching configurations, ensure the target project configuration file exists in Configurations/ and that MCP_CONFIG_NAME matches the file name (without extension).
  • If you experience connectivity or permission issues, use the provided TestConnection and GetSchemaInfo tools to validate connectivity and access scopes before running queries via Claude.
  • For Claude Desktop setup, ensure the path to the built MCP server executable matches your build output and that the environment variable MCP_CONFIG_NAME is set correctly.

Related MCP Servers

Sponsor this space

Reach thousands of developers