mssql-onpremises

mssql-onpremises

Enables AI assistants to connect to on-premises SQL Server databases using natural language for queries, schema management, and data operations.

Category
访问服务器

README

MSSQL On-Premises MCP Server

<div align="center"> <img src="./src/img/logo.png" alt="MSSQL On-Premises MCP Server Logo" width="400"/> </div>

What is this? 🤔

This is a Model Context Protocol (MCP) server specifically designed for on-premises SQL Server databases. It enables AI assistants like GitHub Copilot and Claude to interact directly with your local SQL Server instances using traditional SQL Server authentication.

Key Difference: This version has been adapted from the original Azure SQL samples to work with on-premises SQL Server installations, removing Azure Active Directory dependencies and cloud-specific authentication requirements.

Quick Example

You: "Show me all customers from New York"
GitHub Copilot: *connects to your local SQL Server and returns the results*

How Does It Work? 🛠️

This server leverages the Model Context Protocol (MCP), a versatile framework that acts as a universal translator between AI models and databases. It supports multiple AI assistants including GitHub Copilot and Claude Desktop.

What Can It Do? 📊

  • Connect to on-premises SQL Server instances using SQL Server authentication
  • Run queries using natural language - no SQL knowledge required
  • Create, read, update, and delete data securely
  • Manage database schema (tables, indexes)
  • Secure connection handling with certificate trust options
  • Real-time data interaction with local databases

Quick Start 🚀

Prerequisites

  • Node.js 16+ installed on your system
  • SQL Server instance (local, on-premises, or Docker)
  • SQL Server Authentication enabled on your SQL Server instance
  • Claude Desktop or GitHub Copilot

Installation

  1. Clone the Repository

    git clone https://github.com/dnldelarosa/mssql-mcp-onpremises.git
    cd mssql-mcp-onpremises
    
  2. Install Dependencies

    npm install
    
  3. Build the Project

    npm run build
    

Configuration Setup

Option 1: GitHub Copilot Setup

  1. Install GitHub Copilot Extension

    • Open VS Code
    • Go to Extensions (Ctrl+Shift+X)
    • Search for "GitHub Copilot" and install the official extension.
  2. Create MCP Configuration File

    • Create a .vscode/mcp.json file in your workspace
    • Add the following configuration:
    {
      "servers": {
        "mssql-onpremises": {
           "type": "stdio",
           "command": "node",
           "args": ["C:/path/to/your/project/dist/index.js"],
           "env": {
             "SERVER_NAME": "localhost",
             "DATABASE_NAME": "your-database-name",
             "DB_USER": "your-sql-username",
             "DB_PASSWORD": "your-sql-password",
             "READONLY": "false",
             "TRUST_SERVER_CERTIFICATE": "true"
           }
         }
       }
    }
    

    Note: Ensure the path to dist/index.js is correct.

  3. Alternative: User Level MCP Configuration

    • Open the Command Palette (Ctrl+Shift+P)
    • Type MCP:... (JSON) and press Enter.
    • Add the following configuration to your user's mcp.json file:
 {
  "mcp": {
      "servers": {
          "mssql-onpremises": {
              "command": "node",
              "args": ["C:/path/to/your/project/dist/index.js"],
              "env": {
                "SERVER_NAME": "localhost",
                "DATABASE_NAME": "your-database-name",
                "DB_USER": "your-sql-username",
                "DB_PASSWORD": "your-sql-password",
                "READONLY": "false",
                "TRUST_SERVER_CERTIFICATE": "true"
              }
          }
      }
  }
}
  1. Restart VS Code

    • Close and reopen VS Code for the changes to take effect
  2. Verify MCP Server

    • Open Command Palette (Ctrl+Shift+P)
    • Run "MCP: List Servers" to verify your server is configured
    • You should see "mssql-onpremises" in the list of available servers

Option 2: Claude Desktop Setup

  1. Open Claude Desktop Settings

    • Navigate to File → Settings → Developer → Edit Config
    • Open the claude_desktop_config file
  2. Add MCP Server Configuration Replace the content with the configuration below, updating the path and credentials:

    {
      "mcpServers": {
        "mssql-onpremises": {
          "command": "node",
          "args": ["C:/path/to/your/project/dist/index.js"],
          "env": {
            "SERVER_NAME": "localhost",
            "DATABASE_NAME": "your-database-name",
            "DB_USER": "your-sql-username",
            "DB_PASSWORD": "your-sql-password",
            "READONLY": "false",
            "TRUST_SERVER_CERTIFICATE": "true"
          }
        }
      }
    }
    
  3. Restart Claude Desktop

    • Close and reopen Claude Desktop for the changes to take effect

Configuration Parameters

  • SERVER_NAME: Your SQL Server instance (e.g., localhost, 192.168.1.100, or MYSERVER\SQLEXPRESS)
  • DATABASE_NAME: Your database name
  • DB_USER: SQL Server username for authentication
  • DB_PASSWORD: SQL Server password for authentication
  • READONLY: Set to "true" to restrict to read-only operations, "false" for full access
  • TRUST_SERVER_CERTIFICATE: Set to "true" to trust self-signed certificates (recommended for local development)
  • CONNECTION_TIMEOUT: (Optional) Connection timeout in seconds. Defaults to 30 if not set
  • Path: Update the path in args to point to your actual project location

Sample Configurations

You can find sample configuration files in the src/samples/ folder:

  • claude_desktop_config.json - For Claude Desktop
  • vscode_agent_config.json - For GitHub Copilot

Usage Examples

Once configured, you can interact with your database using natural language:

  • "Show me all users from New York"
  • "Create a new table called products with columns for id, name, and price"
  • "Update all pending orders to completed status"
  • "List all tables in the database"

Security Notes

  • The server requires a WHERE clause for read operations to prevent accidental full table scans
  • Update operations require explicit WHERE clauses for security
  • Set READONLY: "true" in production environments if you only need read access

🛠️ Troubleshooting

Common Issues

Connection Failed

  • Ensure SQL Server Authentication is enabled
  • Verify firewall settings allow connections on SQL Server port (default 1433)
  • Check if TRUST_SERVER_CERTIFICATE is set to "true" for self-signed certificates

"Login failed for user" Error

  • Verify username and password are correct
  • Ensure the SQL Server user has appropriate database permissions
  • Check if the user account is not locked or disabled

MCP Server Not Listed

  • Restart your AI assistant (Claude Desktop / GitHub Copilot)
  • Verify the path to dist/index.js is correct
  • Check the MCP configuration syntax for any JSON errors

Build Errors

  • Ensure Node.js 16+ is installed
  • Delete node_modules and run npm install again
  • Check for TypeScript compilation errors

Getting Help

  • Check the Issues page
  • Review the ATTRIBUTION.md for technical details
  • See original Microsoft samples for additional context

You should now have successfully configured the MCP server for on-premises SQL Server with your preferred AI assistant. This setup allows you to seamlessly interact with your local SQL Server through natural language queries!

📄 License

MIT License - See LICENSE file for details

🙏 Acknowledgments

Based on the original work from Microsoft SQL-AI-samples, modified to support on-premises SQL Server installations.

See ATTRIBUTION.md for detailed information about the original work and modifications made for on-premises support.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选