SQL Server MCP (macOS)

平台与服务

by tharanabope

面向 macOS 的 SQL Server MCP,集成 RAG 能力,并支持通过 Docker 运行 SQL Server。

什么是 SQL Server MCP (macOS)

面向 macOS 的 SQL Server MCP,集成 RAG 能力,并支持通过 Docker 运行 SQL Server。

README

SQL Server MCP - Cross-Platform Database Integration for AI

License: MIT TypeScript MCP npm version npm downloads

A Model Context Protocol (MCP) server implementation for SQL Server that enables AI assistants to explore and query SQL Server databases through natural language. Built as a RAG (Retrieval-Augmented Generation) system optimized for database knowledge exploration.

🌟 Features

  • 🔍 Schema Exploration - List databases, tables, views, stored procedures
  • 🔗 Relationship Mapping - Discover foreign key relationships and table dependencies
  • 🔎 Search & Discovery - Global schema search across tables, columns, procedures
  • Safe Query Execution - Read-only SELECT queries with automatic timeouts and row limits
  • 🗄️ Schema Caching - Fast retrieval with configurable TTL (default: 60 minutes)
  • 🔐 Security First - Read-only by default, SQL injection prevention, query validation
  • 🖥️ Cross-Platform - Native Windows Authentication & macOS Docker support

🎥 Demo

See SQL Server MCP in action with AI assistant integration:

SQL Server MCP Demo

Note: Watch how natural language queries instantly explore database schemas, find relationships, and retrieve data - all without leaving your AI assistant!

🚀 Quick Start

This repository contains two platform-specific implementations:

Windows Versionsql-server-mcp/

  • Windows Authentication (ODBC Driver 17)
  • ✅ SQL Server Authentication
  • ✅ Native msnodesqlv8 driver for optimal performance
  • 📖 Windows Setup Guide

macOS Versionsql-server-mcp-mac/

  • ✅ SQL Server Authentication (Docker required)
  • ✅ Pure JavaScript mssql driver (no native dependencies)
  • 📖 macOS Setup Guide

📦 Installation

🎉 Now Available on MCP Registry!

This server is officially published in the Model Context Protocol Registry:

  • Windows: io.github.TharanaBope/sql-server-mcp
  • macOS: io.github.TharanaBope/sql-server-mcp-macos

🚀 Quick Start (Recommended)

No installation needed! Just add to your AI assistant's configuration:

Claude Desktop (Windows)

Config Location: %APPDATA%\Claude\claude_desktop_config.json

json
{
  "mcpServers": {
    "sql-server": {
      "command": "npx",
      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],
      "env": {
        "SQL_SERVER": "localhost",
        "SQL_DATABASE": "master",
        "SQL_USE_WINDOWS_AUTH": "true"
      }
    }
  }
}

Claude Desktop (macOS)

Config Location: ~/Library/Application Support/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "sql-server": {
      "command": "npx",
      "args": ["-y", "@tharanabopearachchi/sql-server-mcp-macos@latest"],
      "env": {
        "SQL_SERVER": "localhost",
        "SQL_DATABASE": "master",
        "SQL_USE_WINDOWS_AUTH": "false",
        "SQL_USERNAME": "sa",
        "SQL_PASSWORD": "your_password"
      }
    }
  }
}
<details> <summary><b>LM Studio Configuration</b></summary>

Config Location: Varies by platform

  • Windows: %USERPROFILE%\.lmstudio\config.json
  • macOS: ~/.lmstudio/config.json
json
{
  "mcpServers": {
    "sql-server": {
      "command": "npx",
      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],
      "env": {
        "SQL_SERVER": "localhost",
        "SQL_DATABASE": "master",
        "SQL_USE_WINDOWS_AUTH": "true",
        "SQL_USERNAME": "",
        "SQL_PASSWORD": ""
      }
    }
  }
}
</details> <details> <summary><b>VS Code with Continue Extension</b></summary>

Config Location: ~/.continue/config.json

json
{
  "experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "type": "stdio",
          "command": "npx",
          "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"]
        },
        "env": {
          "SQL_SERVER": "localhost",
          "SQL_DATABASE": "master",
          "SQL_USE_WINDOWS_AUTH": "true"
        }
      }
    ]
  }
}
</details> <details> <summary><b>Cursor IDE</b></summary>

Config Location: Cursor Settings → Features → Model Context Protocol

json
{
  "mcpServers": {
    "sql-server": {
      "command": "npx",
      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],
      "env": {
        "SQL_SERVER": "localhost",
        "SQL_DATABASE": "master",
        "SQL_USE_WINDOWS_AUTH": "true"
      }
    }
  }
}
</details> <details> <summary><b>Cline (VS Code Extension)</b></summary>

Config Location: VS Code Settings → Cline → MCP Settings

json
{
  "mcpServers": {
    "sql-server": {
      "command": "npx",
      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],
      "env": {
        "SQL_SERVER": "localhost",
        "SQL_DATABASE": "master",
        "SQL_USE_WINDOWS_AUTH": "true"
      }
    }
  }
}
</details>

Restart your AI assistant and you're ready to go!

🛠️ Development Setup

For development or local modifications:

Windows

bash
cd sql-server-mcp
npm install
npm run build

👉 Complete Windows Setup Instructions

macOS

bash
cd sql-server-mcp-mac
npm install
npm run build

👉 Complete macOS Setup Instructions

🛠️ Available MCP Tools

The server provides 12 powerful tools for database exploration:

Schema Exploration

  • list_databases - Discover all available databases
  • list_tables - View tables with row counts
  • describe_table - Get detailed schema (columns, types, constraints, indexes)
  • list_views - List all views
  • list_stored_procedures - List stored procedures with metadata
  • get_procedure_definition - Get full SQL definition
  • get_database_overview - High-level statistics

Relationship Mapping

  • get_table_relationships - Get foreign key relationships (incoming & outgoing)
  • get_related_tables - Find directly connected tables

Search & Discovery

  • search_schema - Search across tables, columns, views, procedures
  • find_column_usage - Find all tables containing a specific column

Query Execution

  • execute_query - Execute read-only SELECT queries safely

💬 Example Usage

Once configured, you can ask your AI assistant:

code
"What databases are available on this server?"

"Show me all tables in the Sales database"

"What's the schema of the Orders table?"

"Find all tables that reference the Customers table"

"Search for any columns related to 'email'"

"Execute: SELECT TOP 10 * FROM Products ORDER BY Price DESC"

⚙️ Configuration

Both versions use environment variables for configuration:

env
SQL_SERVER=localhost
SQL_DATABASE=master
SQL_PORT=1433
SQL_USE_WINDOWS_AUTH=true          # Windows only
SQL_USERNAME=                       # For SQL Auth
SQL_PASSWORD=                       # For SQL Auth
QUERY_TIMEOUT=30
MAX_RESULT_ROWS=1000
ENABLE_SCHEMA_CACHE=true
CACHE_TTL_MINUTES=60

See platform-specific READMEs for detailed configuration instructions.

🔐 Security Features

  • Read-only by default - Write operations disabled unless explicitly enabled
  • Query validation - Only SELECT statements allowed by default
  • Automatic timeouts - Prevents long-running queries
  • Row limits - Prevents memory exhaustion
  • SQL injection prevention - Query sanitization and validation
  • Database whitelisting - Optional restriction to specific databases

🏗️ Architecture

code
MCP/
├── sql-server-mcp/              # Windows implementation
│   ├── src/
│   │   ├── index.ts             # MCP server entry point
│   │   ├── database/            # Connection, caching, queries
│   │   ├── tools/               # 12 MCP tools
│   │   └── types/               # TypeScript interfaces
│   ├── dist/                    # Compiled output
│   ├── package.json
│   └── README.md                # Windows documentation
│
├── sql-server-mcp-mac/          # macOS implementation
│   ├── src/                     # Same structure as Windows
│   └── README.md                # macOS documentation
│
├── LICENSE                      # MIT License
└── README.md                    # This file

🎯 Use Cases

Database Exploration

  • "What tables exist in this database?"
  • "Show me the structure of the Users table"
  • "List all stored procedures"

Schema Research

  • "Find all tables with an 'email' column"
  • "Search for anything related to 'invoice'"
  • "What views are available?"

Relationship Analysis

  • "How are Orders and Customers related?"
  • "Show me all tables that reference Products"
  • "What are the foreign key relationships for this table?"

Data Queries

  • "Get the top 10 most expensive products"
  • "Show me recent orders"
  • "What's the total count of records in each table?"

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📚 Resources

🌐 Platform-Specific Documentation

PlatformDirectoryKey Features
Windowssql-server-mcp/Windows Auth, ODBC Driver, Native performance
macOSsql-server-mcp-mac/Docker SQL Server, Pure JS, No native deps

Made with ❤️ for the MCP community

Star this repo if you find it useful! 🐛 Report bugs via Issues 💬 Questions? Check the Discussions

常见问题

SQL Server MCP (macOS) 是什么?

面向 macOS 的 SQL Server MCP,集成 RAG 能力,并支持通过 Docker 运行 SQL Server。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描114.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描114.1k

MCP服务构建器

by alirezarezvani

Universal
热门

从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。

帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。

平台与服务
未扫描10.2k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
83.4k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.4k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
35.4k

评论