IC

ian-cowley/mcpsqlserver

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

19 stars 8 forks 质量 69 趋势 26MIT

SQL Server MCP Server - A standalone MCP server providing SQL Server integration capabilities

概览

A standalone MCP (Model Context Protocol) server written in C# that provides SQL Server integration capabilities for any MCP-compliant IDE or client. - SQL Server connectivity - Database schema exploration - Table and view inspection - Column metadata retrieval - Stored procedure enumeration - SQL query execution - Stored procedure execution - Debug mode for troubleshooting - Configurable logging path - : Automatically resolves and overrides database connection strings dynamically based on the active file in the editor - .NET 10.0 SDK or higher - SQL Server instance (local or remote) - SQL Server client tools 2. Configure the application: - Copy appsettings.example.json to appsettings.json - Update the connection string and other settings in appsettings.json with your SQL Server details 3. Configure the MCP server in your IDE / client: - Add the server configuration to your IDE's MCP config file (e.g., Windsurf, Claude Desktop config, or Cline/Cursor settings).

README

以下为原文 README 节选,完整内容请查看原文。

SQL Server MCP Server

A standalone MCP (Model Context Protocol) server written in C# that provides SQL Server integration capabilities for any MCP-compliant IDE or client.

Features

  • SQL Server connectivity
  • Database schema exploration
  • Table and view inspection
  • Column metadata retrieval
  • Stored procedure enumeration
  • SQL query execution
  • Stored procedure execution
  • Debug mode for troubleshooting
  • Configurable logging path
  • Dynamic Project Connection Resolver: Automatically resolves and overrides database connection strings dynamically based on the active file in the editor

Prerequisites

  • .NET 10.0 SDK or higher
  • SQL Server instance (local or remote)
  • SQL Server client tools

Setup

  1. Build the project:
dotnet build
  1. Configure the application:

    • Copy appsettings.example.json to appsettings.json
    • Update the connection string and other settings in appsettings.json with your SQL Server details
    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=your-server;Database=master;User ID=your-username;Password=your-password;TrustServerCertificate=True"
      },
      "LogPath": "C:\\Path\\To\\Your\\LogDirectory\\",
      "DebugMode": "false"
    }
    
  2. Configure the MCP server in your IDE / client:

    • Add the server configuration to your IDE’s MCP config file (e.g., Windsurf, Claude Desktop config, or Cline/Cursor settings).
    • Point the command to the path of your built executable:
    {
      "mcpServers": {
        "sqlMcpService": {
          "command": "path/to/your/MCPSqlServer.exe",
          "args": [],
          "description": "SQL Server MCP Service"
        }
      }
    }
    
  3. Set up GitHub integration:

    • Create a new GitHub repository for your project
    • Initialize a new Git repository in your project directory using git init
    • Add your GitHub repository as a remote using git remote add origin
    • Push your changes to the remote repository using git push -u origin master

Configuration Options

The appsettings.json file contains the following configuration options:

  • ConnectionStrings:DefaultConnection: The SQL Server connection string
  • LogPath: Directory where log files will be stored
  • DebugMode: Set to “true” to enable detailed debug logging
  • AllowWorkspaceOverride: Set to “false” to disable dynamic project connection overrides (defaults to “true”)

Dynamic Project Connection Resolver

In multi-project workspaces where different folders or subprojects connect to different databases, you can avoid updating the main configuration constantly:

  1. All database tools accept an optional currentFilePath parameter (typically automatically populated by the IDE client with the active file’s path).
  2. The server walks up the directory tree from the file’s parent folder looking for the nearest appsettings.json.
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "sqlMcpService": { "command": "path/to/your/MCPSqlServer.exe", "args": [], "description": "SQL Server MCP Service" } } }