AM

aaronontheweb/mssql-mcp

开发工具

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

159 stars 23 forks 质量 75 趋势 0Apache-2.0

aaronontheweb/mssql-mcp 是从 https://github.com/aaronontheweb/mssql-mcp. 导入的 MCP 服务器候选服务器。

概览

aaronontheweb/mssql-mcp 是从 https://github.com/aaronontheweb/mssql-mcp. 导入的 MCP 服务器候选服务器。

概述(AI 翻译)

A .基于NET的模型上下文协议(MCP)服务器,适用于Microsoft SQL Server。

摘要

为什么会有这样的方案?因为市面上其他的MCP解决方案通常都很糟糕,根本无法正常工作——尤其是在Windows上。

该MCP服务器通过一个干净、架构良好的.NET应用程序,利用 Akka.NET 进行内部协调,并采用官方MCP C# SDK,实现协议合规,为AI代理提供对Microsoft SQL Server数据库的强大可靠访问。

特色

  • 模式发现:AI代理可以在不编写复杂SQL的情况下探索数据库结构
  • 查询执行:对SELECT、INSERT、UPDATE、DELETE和DDL操作的全面SQL支持
  • 连接验证:启动时自动数据库连接验证
  • 错误处理:全面的错误处理,包含清晰且可操作的错误信息
  • 表格格式:以易读表格格式化的查询结果供AI使用。
  • Docker 支持:通过内置 .NET Docker 工具实现简便部署

可用工具

工具 描述
execute_sql 对数据库执行任意SQL查询

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

README

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

mssql-mcp

A .NET-powered Model Context Protocol (MCP) server for Microsoft SQL Server.

Abstract

Why does this exist? Because the other MCP solutions in market for this are generally janky pieces of shit that don’t work - certainly not on Windows.

This MCP server provides AI agents with robust, reliable access to Microsoft SQL Server databases through a clean, well-architected .NET application using Akka.NET for internal coordination and the official MCP C# SDK for protocol compliance.

Features

  • Schema Discovery: AI agents can explore database structure without writing complex SQL
  • Query Execution: Full SQL support for SELECT, INSERT, UPDATE, DELETE, and DDL operations
  • Connection Validation: Automatic database connectivity validation on startup
  • Error Handling: Comprehensive error handling with clear, actionable error messages
  • Table Formatting: Query results formatted in readable tables for AI consumption
  • Docker Support: Easy deployment with built-in .NET Docker tooling

Available Tools

Tool Description
execute_sql Execute any SQL query against the database
list_tables List all tables with schema, name, type, and row count
list_schemas List all available schemas/databases in the SQL Server instance

Configuration

Required Environment Variables

The MCP server requires a single environment variable:

  • MSSQL_CONNECTION_STRING: Complete SQL Server connection string

Example Connection Strings

Windows Authentication:

MSSQL_CONNECTION_STRING="Server=localhost;Database=MyDatabase;Trusted_Connection=true;"

SQL Server Authentication:

MSSQL_CONNECTION_STRING="Server=localhost;Database=MyDatabase;User Id=myuser;Password=mypassword;"

Azure SQL Database:

MSSQL_CONNECTION_STRING="Server=myserver.database.windows.net;Database=mydatabase;User Id=myuser;Password=mypassword;Encrypt=true;"

Running the MCP Server

The easiest way to run the MCP server is using Docker with .NET’s built-in container support.

Build and Run with Docker

Clone the repository

# Clone the repository
git clone https://github.com/Aaronontheweb/mssql-mcp.git
cd mssql-mcp

Build the Docker image

dotnet publish --os linux --arch x64 /t:PublishContainer

You can run the container directly if you wish, but it’s probably best to let the MCP server spin up the client:

# Run the container
docker run -it --rm \
  -e MSSQL_CONNECTION_STRING="Server=host.docker.internal;Database=MyDB;Trusted_Connection=true;" \
  mssql-mcp:latest

MCP Client Configuration

Cursor IDE

Add to your Cursor settings (Cursor Settings > Features > Model Context Protocol):

{
  "mcpServers": {
    "mssql": {
      "command": "docker",
      "args": [
          "run",
          "-i",
          "--rm",
          "-e",
          "MSSQL_CONNECTION_STRING",
在 GitHub 查看完整 README

安装

docker run -i --rm -e MSSQL_CONNECTION_STRING mssql-mcp:latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mssql": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "MSSQL_CONNECTION_STRING", "mssql-mcp:latest" ], "env": { "MSSQL_CONNECTION_STRING": "Server=host.docker.internal,1533; Database=MyDb; User Id=myUser; Password=My(!)Password;TrustServerCertificate=true;" } } } }