This server provides a high-performance MSSQL database management interface through the Model Context Protocol (MCP), leveraging Bun runtime for exceptional speed and offering secure, permission-controlled database operations.
Core Database Operations:
Connect to MSSQL databases with configurable connection parameters (server, port, credentials, encryption)
List available user databases and switch between different databases on the same server
Discover and list tables within the current database
Inspect database schema by describing table structures, fields, and column information
Execute SQL queries with optional result limits (default 100 rows)
Monitor connection status and explicitly disconnect when needed
Security & Permissions:
Granular permission control via environment variables with four modes: read-only (default), write, full (insert/update/delete), and danger mode
Secure connection options including encryption and authentication controls
Performance & Integration:
High-performance Bun runtime delivering faster startup and lower memory footprint compared to traditional Node.js
Seamless Claude Code integration through
.mcp.json
configuration for simplified setupMultiple deployment methods including direct TypeScript execution, Bunx auto-install, or compiled standalone binaries
Uses .env files to manage environment variables for database connection configurations, supporting flexible deployment across different environments.
Leverages npm for package management, installation of dependencies, and running build and development scripts for the MCP server.
Utilizes TypeScript for type definitions and project structure, with the codebase organized into TypeScript modules for database management and type definitions.
MSSQL MCP Server - Bunx Edition 🚀
使用 Bun 和 Bunx 驅動的高效能 MSSQL MCP 伺服器,比傳統 Node.js 快 100 倍!
🎯 核心優勢
- ⚡ 極速啟動: 利用 Bun 的快速啟動時間,比 npx 快約 100 倍
- 📦 原生 TypeScript: 無需編譯,直接執行 TypeScript 程式碼
- 🔄 自動安裝: Bunx 自動管理依賴套件
- 💾 全域快取: 智慧快取機制,避免重複下載
- 🏗️ 獨立執行檔: 可編譯為單一執行檔,無需安裝 runtime
📋 先決條件
🚀 快速開始
方法 1: 使用 Bunx (推薦 - 無需安裝)
方法 2: 使用 npm/npx
方法 3: 開發模式
方法 4: 編譯獨立執行檔
🔒 安全性與權限控制
環境變數權限設定
MSSQL MCP Server 預設為唯讀模式,只允許執行 SELECT 查詢。你可以透過環境變數啟用不同的權限層級:
環境變數 | 說明 | 預設值 |
---|---|---|
MSSQL_ALLOW_INSERT | 允許 INSERT 操作 | false |
MSSQL_ALLOW_UPDATE | 允許 UPDATE 操作 | false |
MSSQL_ALLOW_DELETE | 允許 DELETE 操作 | false |
MSSQL_DANGER_MODE | Danger 模式) | false |
預設啟動模式
Windows 環境設定
🔧 Claude Code 整合
1. 自動設定 (使用 .mcp.json)
專案已包含 .mcp.json
設定檔,Claude Code 會自動偵測:
2. 手動設定選項
編輯 mcp-config-bun.json
選擇不同的執行模式:
3. 帶權限設定的 MCP 配置
在 Claude Code 的 MCP 配置中加入環境變數來控制權限:
💡 提示:你可以在 Claude Code 中同時配置多個不同權限等級的 MSSQL 伺服器,根據需求選擇使用。
📊 效能比較
執行方式 | 啟動時間 | 記憶體使用 | 特點 |
---|---|---|---|
bunx --bun | ~10ms | 低 | 最快,自動管理依賴 |
bun run | ~8ms | 最低 | 開發模式,即時執行 |
npm/npx | ~1000ms | 高 | 傳統方式,較慢 |
獨立執行檔 | ~5ms | 中 | 無需 runtime,部署簡單 |
🛠️ 開發指令
🐛 故障排除
Bunx 找不到套件
權限問題
Claude Code 無法連接
- 確認 Bun 已正確安裝:
bun --version
- 檢查
.mcp.json
設定 - 重新載入 Claude Code 視窗
🔍 測試執行
📦 發布到 npm
🎯 最佳實踐
- 開發階段: 使用
bun run dev
快速迭代 - 測試階段: 使用
bunx --bun mssql-mcp
測試套件執行 - 生產部署: 編譯為獨立執行檔,無需安裝 runtime
- Claude Code: 使用
.mcp.json
自動設定
🚄 為什麼選擇 Bun?
- 速度: 啟動時間比 Node.js 快 100 倍
- 原生 TypeScript: 無需 ts-node 或編譯步驟
- 內建工具: 包含套件管理、測試、打包等功能
- 相容性: 高度相容 Node.js 生態系統
- 效能: 更低的記憶體使用和 CPU 消耗
📚 相關資源
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables interaction with Microsoft SQL Server databases through a Model Context Protocol interface, supporting database connections, switching between databases, and executing secure SELECT queries.
Related MCP Servers
- AsecurityAlicenseAqualityEnables execution of SQL queries and management of Microsoft SQL Server database connections through the Model Context Protocol.Last updated -338114MIT License
- -securityAlicense-qualityA Model Context Protocol server that enables secure and structured interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries with controlled access.Last updated -47MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -226MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables executing SQL queries and managing connections with Microsoft SQL Server databases.Last updated -1816MIT License