MCP-SqlServer
A MCP Server implementation in C# for LLM integration with SQL Server tested with Claude Desktop
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:
- Install .NET SDK
# example for Windows
winget install Microsoft.DotNet.SDK.7
- Clone or download the MCP-SqlServer project to your machine.
- Ensure the environment variable for the SQL Server connection string is prepared (see env.database below).
- Build or run the project:
# From the project directory
dotnet build
dotnet run --project path\to\MCP-SqlServer --no-build
- 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
time
⏰ Time MCP Server: Giving LLMs Time Awareness Capabilities
advanced-homeassistant
An advanced MCP server for Home Assistant. 🔋 Batteries included.
workflowy
Powerful CLI and MCP server for WorkFlowy: reports, search/replace, backup support, and AI integration (Claude, LLMs)
runjs
The only MCP server you need: let your LLM generate and safely execute JavaScript -- including fetch API calls, JSONPath ETL, built-in resiliencey, and secrets management
roslyn
MCP server from egorpavlikhin/roslyn-mcp
cco
Real-time audit and approval system for Claude Code tool calls.