Microsoft SQL MCPサーバー
AIクライアントがSQL Serverのスキーマを探索し、安全に読み取り専用のSELECTクエリを実行できるようにします。
別名 bilims/mcp-sqlserver, @bilims/mcp-sqlserver
- スター
- 47
- ツール
- 8
- ダウンロード数(30日間)
- 4,376
- 最新バージョン
- —
- 最終コミット
- 2026年3月31日
- ライセンス
- MIT
Microsoft SQL MCPとは
Microsoft SQLはMCPサーバーです。 AIクライアントがSQL Serverのスキーマを探索し、安全に読み取り専用のSELECTクエリを実行できるようにします。. 8個のツールを提供しており、list_databases, list_tables, list_viewsなどがあります。
プロジェクトのREADMEから生成された概要
Microsoft SQL MCP server について
このサーバーは、AIクライアントからMicrosoft SQL Serverのスキーマを探索し、読み取り専用クエリを実行することを可能にします。開発者やデータアナリストは、Claude DesktopやClaude Code CLIなどのツールを通じて、Azure SQL Database、オンプレミスのSQL Server、またはローカルのSQL Server Expressインスタンスに対して、自然言語で操作を行うことができます。サーバーは、ホスト、ユーザー、パスワード、データベース名などの環境変数を使用してデータベースに接続します。
セキュリティを最優先事項として設計されており、誤ったデータ変更を防ぐために操作を読み取り専用のSELECT文に制限しています。SQLインジェクションに対する組み込みの保護機能が含まれており、INSERTやDELETEなどの危険なキーワードをブロックするためのブラックリストを使用しています。ユーザーは、list_tables、describe_table、get_foreign_keysなどのツールを使用してデータベース構造を探索できます。データ取得については、execute_queryツールを使用することで、設定可能な行数制限やタイムアウト機能とともに、安全な探索が可能です。複雑なクエリ実行時でも安定性を確保できます。
できること
- 1データベース構造の探索特定のデータベーススキーマ内にあるすべてのテーブルと、そのカラム定義をAIに特定させます。
- 2テーブル間のリレーションシップ分析外部キーを通じて異なるテーブルがどのように接続されているかの要約をリクエストします。
- 3サンプルデータの取得自然言語を使用して、特定のテーブルから調査用の限定的なレコードセットを取得します。
- 4テーブルサイズの監査データベース内のどのテーブルが最も多くの容量を消費しているか、または最も多くの行を含んでいるかを特定します。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
Microsoft SQL MCPのインストール方法
フォーマット検証日 2026年11月10日Cursor に追加Gooseに追加Claude CodeにMicrosoft SQL MCPをインストール
$ claude mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserverCursorにMicrosoft SQL MCPをインストール
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}VS CodeにMicrosoft SQL MCPをインストール
.vscode/mcp.json
{
"servers": {
"mcp-sqlserver": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}VS Code CLIにMicrosoft SQL MCPをインストール
$ code --add-mcp '{"name":"mcp-sqlserver","type":"stdio","command":"npx","args":["-y","@bilims/mcp-sqlserver"]}'Claude DesktopにMicrosoft SQL MCPをインストール
claude_desktop_config.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}CodexにMicrosoft SQL MCPをインストール
$ codex mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserverCodex config.tomlにMicrosoft SQL MCPをインストール
~/.codex/config.toml
[mcp_servers.mcp-sqlserver] command = "npx" args = ["-y", "@bilims/mcp-sqlserver"]
Gemini CLIにMicrosoft SQL MCPをインストール
$ gemini mcp add -s user mcp-sqlserver npx -- -y @bilims/mcp-sqlserverGemini settings.jsonにMicrosoft SQL MCPをインストール
~/.gemini/settings.json
{
"mcpServers": {
"mcp-sqlserver": {
"command": "npx",
"args": [
"-y",
"@bilims/mcp-sqlserver"
]
}
}
}Microsoft SQL MCPツール 8
READMEから検出list_databaseslist_tableslist_viewsdescribe_tableget_foreign_keysget_table_statsexecute_queryget_server_info
| list_databases | — | |
| list_tables | — | |
| list_views | — | |
| describe_table | — | |
| get_foreign_keys | — | |
| get_table_stats | — | |
| execute_query | — | |
| get_server_info | — |
設定
SQLSERVER_DATABASESQLSERVER_ENCRYPTSQLSERVER_HOSTSQLSERVER_PASSWORDSQLSERVER_TRUST_CERTSQLSERVER_USER
| 名前 | 説明 | 種類 |
|---|---|---|
| SQLSERVER_DATABASE | — | |
| SQLSERVER_ENCRYPT | — | |
| SQLSERVER_HOST | — | |
| SQLSERVER_PASSWORD | — | |
| SQLSERVER_TRUST_CERT | — | |
| SQLSERVER_USER | — |
自動チェック
実行日 2026年11月14日完全なレポート →まだ検証されていません。サーバーには80点のスコア、重大な問題がないこと、および検証に必要な十分なデータが必要です。 チェックの仕組み · 点数を上げるための改善点
- ソースリポジトリがリンクされており、アクセス可能bilims/mcp-sqlserver is public and reachablegithub.com/bilims/mcp-sqlserver ↗合格
- パッケージがこのリポジトリをソースとして指定@bilims/mcp-sqlserver names bilims/mcp-sqlserver as sourcenpmjs.com/package/@bilims/mcp-sqlserver ↗合格
- ビルドの来歴 (Sigstore 証明)No build attestation published for this release未チェック
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit or release 2026-03-31github.com/bilims/mcp-sqlserver ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していないNo popular package one edit away from @bilims/mcp-sqlserver合格
- パッケージおよびその依存関係に重大な勧告なし未チェック
- モデルへの隠れた指示がない8 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされている未チェック
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見るMCP SQL Server
A read-only Model Context Protocol (MCP) server for Microsoft SQL Server that enables AI agents to safely explore and query SQL Server databases.
Quick Start
Step 1: Install the Package
# Global installation (recommended)
npm install -g @bilims/mcp-sqlserver
# Verify installation
mcp-sqlserver --version
Step 2: Configure Your SQL Server Connection
Choose your SQL Server type and follow the configuration:
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-Premises SQL Server
export SQLSERVER_HOST="your-sql-server.company.com"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true" # For self-signed certificates
Local SQL Server Express
export SQLSERVER_HOST="localhost\\SQLEXPRESS"
export SQLSERVER_USER="sa"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="master"
export SQLSERVER_ENCRYPT="false"
export SQLSERVER_TRUST_CERT="true"
Step 3: Test the Connection
# Test your configuration
mcp-sqlserver --help
# Quick connection test (press Ctrl+C to exit)
mcp-sqlserver
Step 4: Add to Claude Desktop
-
Find your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the MCP server configuration:
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database",
"SQLSERVER_ENCRYPT": "true",
"SQLSERVER_TRUST_CERT": "false"
}
}
}
}
- Restart Claude Desktop
Step 5: Start Exploring!
Try these commands in Claude Desktop:
"Test the SQL Server connection""List all databases on the server""Show me the tables in [database name]""Describe the structure of the Users table""Show me foreign key relationships"
Features
- 🔒 Read-only operations: Only SELECT queries allowed, with comprehensive security validation
- 🗄️ Schema discovery: Explore databases, tables, views, relationships, and metadata
- 📊 Data exploration: Execute safe queries with built-in limits and timeouts
- 🔐 Enterprise-ready: Encrypted connections with certificate trust for production environments
- 🛡️ Security-first: Query validation, SQL injection protection, and access controls
Available Tools
Schema Discovery
list_databases- List all databases on the SQL Server instancelist_tables- List tables in a database or schemalist_views- List views in a database or schemadescribe_table- Get detailed table schema including columns, data types, and constraints
Relationship Analysis
get_foreign_keys- Get foreign key relationships for tablesget_table_stats- Get table statistics including row counts and size information
Data Exploration
execute_query- Execute read-only SELECT queries with safety validationget_server_info- Get SQL Server version, edition, and configuration details
Common Commands for Claude Desktop
Once your MCP server is configured, try these natural language commands:
Getting Started Commands
"Test the SQL Server connection"
"Show me server information"
"List all databases on this server"
"What tables are in the [database name] database?"
Database Exploration
"Describe the structure of the Users table"
"Show me foreign key relationships in this database"
"What are the largest tables by row count?"
"Give me a sample of data from the Orders table"
Advanced Analysis
"Help me understand the relationship between Orders and Customers"
"Show me all lookup tables in this database"
"What columns contain date/time information?"
"Find tables that might contain user authentication data"
Custom Queries
"Run this query: SELECT TOP 10 * FROM Products WHERE Price > 100"
"Show me all customers created in the last 30 days"
"What are the different product categories in the database?"
Installation
npm install
npm run build
Configuration
The server is configured using environment variables:
Required
SQLSERVER_USER- SQL Server usernameSQLSERVER_PASSWORD- SQL Server password
Optional
SQLSERVER_HOST- Server hostname (default: localhost)SQLSERVER_DATABASE- Default database nameSQLSERVER_PORT- Port number (default: 1433)SQLSERVER_ENCRYPT- Enable encryption (default: true)SQLSERVER_TRUST_CERT- Trust server certificate (default: true)SQLSERVER_CONNECTION_TIMEOUT- Connection timeout in ms (default: 30000)SQLSERVER_REQUEST_TIMEOUT- Request timeout in ms (default: 60000)SQLSERVER_MAX_ROWS- Maximum rows per query (default: 1000)
Usage
Environment Variables
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
export SQLSERVER_DATABASE="your-database"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
Running the Server
npm start
Installation Options
Option 1: Global Installation (Recommended)
npm install -g @bilims/mcp-sqlserver
Option 2: Local Installation
npm install @bilims/mcp-sqlserver
npx mcp-sqlserver
Option 3: Run with npx (No Installation)
npx @bilims/mcp-sqlserver
Integration Examples
Claude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"sqlserver": {
"command": "mcp-sqlserver",
"env": {
"SQLSERVER_HOST": "your-server.database.windows.net",
"SQLSERVER_USER": "your-username",
"SQLSERVER_PASSWORD": "your-password",
"SQLSERVER_DATABASE": "your-database"
}
}
}
}
Claude Code CLI
# Set environment variables
export SQLSERVER_HOST="your-server"
export SQLSERVER_USER="your-username"
export SQLSERVER_PASSWORD="your-password"
# Use with Claude Code
claude mcp add sqlserver mcp-sqlserver
VSCode with MCP Extension
Install the MCP extension for VSCode and add the server configuration.
Security Features
Query Validation
- Only SELECT, WITH, SHOW, DESCRIBE, and EXPLAIN statements allowed
- Comprehensive blacklist of dangerous keywords (INSERT, UPDATE, DELETE, DROP, etc.)
- SQL injection pattern detection
- Automatic query sanitization
Connection Security
- TLS/SSL encryption enabled by default
- Server certificate trust options for enterprise environments
- Connection pooling with timeout controls
- Configurable request timeouts
Result Limits
- Maximum row limits per query (configurable)
- Automatic TOP clause injection for SELECT queries
- Query execution time tracking
- Memory usage protection
Example Queries
Once connected, you can use the tools through your MCP client:
// List all databases
await callTool("list_databases", {});
// List tables in a specific schema
await callTool("list_tables", { schema: "dbo" });
// Get table schema details
await callTool("describe_table", {
table_name: "Users",
schema: "dbo"
});
// Execute a read-only query
await callTool("execute_query", {
query: "SELECT TOP 10 * FROM Users WHERE active = 1",
limit: 10
});
// Get foreign key relationships
await callTool("get_foreign_keys", {
table_name: "Orders"
});
Development
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run linting
npm run lint
# Run tests
npm test
Troubleshooting
Connection Issues
- Verify server hostname and port
- Check if encryption/certificate settings match your SQL Server configuration
- Ensure user has appropriate read permissions
- Test connection using SQL Server Management Studio first
Permission Issues
The user account needs at minimum:
CONNECTpermission to the databaseSELECTpermission on tables/views you want to query- Access to system views for metadata queries
Common SQL Server Configurations
Azure SQL Database
export SQLSERVER_HOST="your-server.database.windows.net"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="false"
On-premises SQL Server with self-signed certificates
export SQLSERVER_HOST="sql-server.company.com"
export SQLSERVER_ENCRYPT="true"
export SQLSERVER_TRUST_CERT="true"
License
MIT
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section above
- Review SQL Server connection documentation
- Ensure MCP client compatibility
Built with the Model Context Protocol SDK for seamless AI integration.
Microsoft SQL MCPのよくある質問
Microsoft SQL MCPをClaude Codeに追加するには
ターミナルでclaude mcp add mcp-sqlserver -- npx -y @bilims/mcp-sqlserverを実行します。すべてのプロジェクトで利用するには--scope userを追加します。
Microsoft SQL MCPをCursorに追加するには
~/.cursor/mcp.jsonを開き、上記のインストールセクションに示すCursor設定を使ってmcpServersの下にサーバーを追加します。
Microsoft SQL MCPが提供するツールは
8個のツールを提供しており、list_databases, list_tables, list_views, describe_table, get_foreign_keysなどがあります。
このMCP serverはSQL Server内のデータを変更または削除できますか?
いいえ、読み取り専用です。SELECT、WITH、SHOW、DESCRIBE、EXPLAIN文のみが許可されており、危険なキーワードはブラックリストに登録されています。
SQL Serverへの接続設定はどうすればよいですか?
SQLSERVER_HOST、SQLSERVER_USER、SQLSERVER_PASSWORD、SQLSERVER_DATABASEなどの環境変数と、暗号化オプションを設定してください。
スキーマ探索のためにどのようなツールが提供されていますか?
list_databases、list_tables、list_views、describe_tableのほか、リレーションシップやクエリに関するツールを提供しています。
Azure SQL Databaseでも動作しますか?
はい、Azureの設定では暗号化を有効にし、証明書の信頼を無効にすることで動作します。
クエリで取得できる行数の上限はありますか?
SQLSERVER_MAX_ROWSによってクエリごとの行数が制限されます。デフォルトは1000行です。