Get the FREE Ultimate OpenClaw Setup Guide →

MCP-SqlServer

A MCP Server implementation in C# for LLM integration with SQL Server tested with Claude Desktop

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rodrigopaml-mcp-sqlserver dotnet run --project C:\path\to\MCP-SqlServer --no-build \
  --env database="SQL Server connection string (e.g., Server=...;Database=...;User Id=...;Password=...)"

How to use

MCP-SqlServer is a C# STDIO MCP server that exposes a set of tools to interact with a Microsoft SQL Server database. It registers itself as an MCP service and uses Claude (or similar LLM front-ends) to receive tool commands, execute them against SQL Server, and return structured results. The available tools focus on database health and discovery as well as data querying, enabling the LLM to verify connectivity, inspect schema, and run Ad-hoc queries.

To use it, configure the environment with your SQL Server connection string (env.database), start the server via dotnet run with the project path, then enable the MCP server in your LLM client (Claude Desktop or compatible tool). The client will present the tools under the MCP server, usually labeled as HealthCheck, GetSchema, and Query. HealthCheck verifies the database connection is alive, GetSchema returns tables with their schemas and column types, and Query executes SQL statements and returns results in JSON format for easy consumption by the LLM.

How to install

Prerequisites:

  • .NET SDK (compatible with the MCP-SqlServer project)
  • Access to a Microsoft SQL Server instance
  • A machine capable of building and running the C# project

Steps:

  1. Install .NET SDK
# example for Windows
winget install Microsoft.DotNet.SDK.7
  1. Clone or download the MCP-SqlServer project to your machine.
  2. Ensure the environment variable for the SQL Server connection string is prepared (see env.database below).
  3. Build or run the project:
# From the project directory
dotnet build
dotnet run --project path\to\MCP-SqlServer --no-build
  1. Configure Claude Desktop or your MCP client to point to the server with the provided command and project path. Use the configuration example in the README (adjust the path to your environment).

Additional notes

Tips and common considerations:

  • The server logs to mcp_server.log; monitor this file for troubleshooting.
  • Be mindful that LLMs can issue destructive queries; validate queries or sandbox user input where possible.
  • Ensure the env.database string is correct and that the SQL Server user has appropriate permissions.
  • If you change the project path, update the mcp configuration accordingly.
  • The GetSchema tool returns table-level schema including column types for building queries without hard-coding schema details.

Related MCP Servers

Sponsor this space

Reach thousands of developers