MCP-SqlServer logo

MCP-SqlServer

by RodrigoPAml

MCP-SqlServer is a C# implementation of an MCP Server (STDIO) for integrating LLMs with SQL Server, specifically tested with Claude Desktop. It provides tools for LLMs to interact with and query a SQL Server database.

View on GitHub

Last updated: N/A

MCP-SqlServer

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

The server register logs into a mcp_server.log file

Caution, the LLM can modify your database

Tools

List of tools provided to the LLM

  • HealthCheck: Tests if the Microsoft SQL Server Database connection is good and alive.
  • GetSchema: Get a list of all tables with their respective schema, columns and types.
  • Query: Execute a query into the Microsoft SQL Server database and return the result as a JSON.

Setup with Claude

  1. Fill the env.database with the connection string from your SQL Server
  2. Compile the project
  3. In the Claude Destkop Go File->Configurations->Developer and edit the MCP configuration (claude_desktop_config.json)
  4. Paste the json as:
{
    "mcpServers": {
        "database": {
            "command": "dotnet",
            "args": [
                "run",
                "--project",
                "C:\\Users\\{USER}\\Desktop\\MCP-SqlServer",
                "--no-build"
            ]
        }
    }
}
  1. Restart Claude Desktop

Testing

Open Claude Desktop and if everything is configured well you should be able to see this

image

image

Click on the icon and you should be able to see the tools

image

image

Asking for connection check

image

image

Asking for schema/table informations

image

image

Asking for read query

image

image

Asking for modifications

image

image