RM

richardhan/mssql_mcp_server

数据库管理

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

401 stars 122 forks 质量 72 趋势 20MIT

一款适用于Microsoft SQL Server的模型上下文协议(MCP)服务器,通过受控接口实现安全的数据库交互。

概览

一款模型上下文协议(MCP)服务器,通过 Claude Desktop 实现安全访问 SQL Server 数据库。 - 🔍 列表数据库表 - 📊 执行SQL查询(选择、插入、更新、删除)- 🔐 多种认证方法(SQL、Windows、Azure AD)- 🏢 支持LocalDB和Azure SQL - 🔌 自定义端口配置 - 创建一个权限极少的专用SQL用户 - 绝不使用管理员/SA账户 - 尽量使用Windows认证 - 启用敏感数据加密

概述(AI 翻译)

一款模型上下文协议(MCP)服务器,通过 Claude Desktop 实现安全访问 SQL Server 数据库。

特色

  • 🔍 列表数据库表
  • 📊 执行SQL查询(选择、插入、更新、删除)
  • 🔐 多重认证方法(SQL、Windows、Azure AD)
  • 🏢 LocalDB 和 Azure SQL 支持
  • 🔌 自定义端口配置

快速启动

用 Claude Desktop 安装

在你的claude_desktop_config.json中添加:

配置

基础SQL认证

Windows 认证

Azure SQL 数据库

可选设置

替代安装方法

使用 pip

那么在claude_desktop_config.json中:

发展

安全

  • 创建一个权限最小的专用SQL用户
  • 绝不使用管理员/助理账户
  • 尽可能使用Windows认证
  • 启用敏感数据加密

许可证

麻省理工学院

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

README

Microsoft SQL Server MCP Server

A Model Context Protocol (MCP) server for secure SQL Server database access through Claude Desktop.

Features

  • 🔍 List database tables
  • 📊 Execute SQL queries (SELECT, INSERT, UPDATE, DELETE)
  • 🔐 Multiple authentication methods (SQL, Windows, Azure AD)
  • 🏢 LocalDB and Azure SQL support
  • 🔌 Custom port configuration

Quick Start

Install with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["microsoft_sql_server_mcp"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "your_database",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

Configuration

Basic SQL Authentication

MSSQL_SERVER=localhost          # Required
MSSQL_DATABASE=your_database    # Required
MSSQL_USER=your_username        # Required for SQL auth
MSSQL_PASSWORD=your_password    # Required for SQL auth

Windows Authentication

MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true         # Use Windows credentials

Azure SQL Database

MSSQL_SERVER=your-server.database.windows.net
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Encryption is automatic for Azure

Optional Settings

MSSQL_PORT=1433                 # Custom port (default: 1433)
MSSQL_ENCRYPT=true              # Force encryption

Alternative Installation Methods

Using pip

pip install microsoft_sql_server_mcp

Then in claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": ["-m", "mssql_mcp_server"],
      "env": { ... }
    }
  }
}

Development

git clone https://github.com/RichardHan/mssql_mcp_server.git
cd mssql_mcp_server
pip install -e .

Security

  • Create a dedicated SQL user with minimal permissions
  • Never use admin/sa accounts
  • Use Windows Authentication when possible
  • Enable encryption for sensitive data

License

MIT

在 GitHub 查看完整 README

安装

uvx microsoft_sql_server_mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mssql": { "command": "uvx", "args": ["microsoft_sql_server_mcp"], "env": { "MSSQL_SERVER": "localhost", "MSSQL_DATABASE": "your_database", "MSSQL_USER": "your_username", "MSSQL_PASSWORD": "your_password" } } } }