MCP Microsoft SQL Serverのロゴ

MCP Microsoft SQL Server

コミュニティ
0xhubed

A configurable Model Context Protocol (MCP) server for Microsoft SQL Server integration with Claude Code, supporting project-based database access with secure read/write operations.

公開者0xhubed
リポジトリmcp-ms-sql-server
言語C#
フォーク
9
スター
11
利用可能なツール
0
通信方式stdio
カテゴリ
リンク
  • ツールをAIワークフローに接続

    MCP Microsoft SQL Serverは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには11件のスターと9件のフォークがあります。

MCP Microsoft SQL Server

A configurable Model Context Protocol (MCP) server for Microsoft SQL Server integration with Claude Code and other MCP clients. Enables AI assistants to securely interact with SQL Server databases through project-based configurations with full read/write capabilities.

🌟 Features

🔧 Project-Based Configuration

  • Multiple database connections - Switch between different projects and databases
  • Schema-specific access - Restrict access to specific schemas per project
  • Configurable permissions - Fine-grained control over read/write/delete operations
  • Environment-based setup - Different configurations for dev, staging, and production

🛡️ Security & Safety

  • Transaction management - Automatic rollback on errors for write operations
  • Query validation - Prevent SQL injection and validate all operations
  • WHERE clause enforcement - Mandatory WHERE clauses for UPDATE/DELETE operations
  • Row limit restrictions - Configurable limits to prevent accidental mass operations
  • Audit logging - Track all database operations for accountability

🔍 Database Operations

  • Read Operations: SELECT queries with pagination and filtering
  • Write Operations: INSERT, UPDATE, DELETE with transaction safety
  • Schema Exploration: Browse tables, columns, relationships, and indexes
  • Table Management: Get metadata, statistics, and sample data
  • Configuration Management: Switch between project configurations dynamically

🚀 AI Integration

  • Claude Desktop integration - Seamless setup with Claude Desktop app
  • MCP protocol compliance - Works with any MCP-compatible client
  • Natural language interface - Interact with databases using plain English
  • Error handling - Clear, actionable error messages for AI and humans

📋 Prerequisites

  • .NET 9.0 or later
  • Microsoft SQL Server (any supported version)
  • Claude Desktop (for Claude integration)
  • Appropriate database permissions for the operations you want to perform

🚀 Quick Start

1. Installation

bash
# Clone the repository
git clone https://github.com/yourusername/mcp-ms-sql-server.git
cd mcp-ms-sql-server

# Build the project
dotnet build -c Release

2. Create Project Configuration

Create a configuration file for your project in the Configurations/ directory:

json
// Configurations/my-project.json
{
  "name": "My E-Commerce Project",
  "connectionString": "Server=localhost;Database=ECommerceDB;Integrated Security=true;",
  "allowedSchema": "dbo",
  "permissions": {
    "allowRead": true,
    "allowWrite": true,
    "allowDelete": false
  },
  "security": {
    "requireWhereClause": true,
    "maxRowsPerQuery": 1000,
    "auditOperations": true
  }
}

3. Configure Claude Desktop

Add to your Claude Desktop configuration:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "sql-server": {
      "type": "stdio",
      "command": "C:\\Git\\mcp-ms-sql-server\\McpMsSqlServer\\bin\\Release\\net9.0\\McpMsSqlServer.exe",
      "env": {
        "MCP_CONFIG_NAME": "my-project"
      }
    }
  }
}

Note: First build the project with dotnet build -c Release to create the executable.

4. Start Using

In Claude Desktop, you can now ask:

  • "Show me all tables in the database"
  • "Insert a new customer with name 'John Doe' and email 'john@example.com'"
  • "What are the top 10 products by sales?"
  • "Update the price of product with ID 123 to $29.99"

📖 Configuration Guide

Project Configuration Structure

json
{
  "name": "Project Display Name",
  "connectionString": "Your SQL Server connection string",
  "allowedSchema": "schema_name",
  "permissions": {
    "allowRead": true,
    "allowWrite": true,
    "allowDelete": false,
    "allowSchemaChanges": false
  },
  "security": {
    "requireWhereClause": true,
    "maxRowsPerQuery": 1000,
    "maxRowsPerUpdate": 100,
    "maxRowsPerDelete": 10,
    "auditOperations": true
  },
  "querySettings": {
    "timeoutSeconds": 30,
    "enableQueryPlan": false,
    "allowJoins": true,
    "allowSubqueries": true
  },
  "restrictedTables": ["sensitive_table", "audit_log"],
  "allowedOperations": ["SELECT", "INSERT", "UPDATE", "DELETE"]
}

Example Configurations

json
{
  "name": "Development Database",
  "connectionString": "Server=dev-server;Database=DevDB;Integrated Security=true;",
  "allowedSchema": "dbo",
  "permissions": {
    "allowRead": true,
    "allowWrite": true,
    "allowDelete": true,
    "allowSchemaChanges": true
  },
  "security": {
    "requireWhereClause": false,
    "maxRowsPerQuery": 5000,
    "auditOperations": false
  }
}
json
{
  "name": "Production Database",
  "connectionString": "Server=prod-server;Database=ProdDB;User Id=app_user;Password=secure_password;",
  "allowedSchema": "app",
  "permissions": {
    "allowRead": true,
    "allowWrite": true,
    "allowDelete": false,
    "allowSchemaChanges": false
  },
  "security": {
    "requireWhereClause": true,
    "maxRowsPerQuery": 100,
    "maxRowsPerUpdate": 10,
    "auditOperations": true
  },
  "restrictedTables": ["user_passwords", "payment_info"]
}

🛠️ Available Tools

Configuration Management (4 tools)

  • ListConfigurations - Show all available project configurations
  • SwitchConfiguration - Switch to a different project configuration
  • GetCurrentConfiguration - View current configuration details
  • TestConnection - Test database connectivity

Core Database Operations (6 tools)

  • ExecuteQuery - Run SELECT queries within allowed schema
  • GetSchemaInfo - Explore database structure and objects
  • GetTableInfo - Get table metadata and sample data
  • InsertRecords - Insert new records with transaction support
  • UpdateRecords - Update existing records (requires WHERE clause)
  • DeleteRecords - Delete records (requires WHERE clause)

Advanced Features (6 tools)

  • BuildQuery - Generate SQL queries from natural language
  • AnalyzeQueryPerformance - Analyze query execution plans
  • GetDatabasePerformanceStats - Database performance metrics
  • DiscoverData - Search tables/columns by patterns
  • AnalyzeTableRelationships - Find table relationships
  • ProfileDataQuality - Analyze data quality and statistics

🔒 Security Considerations

Best Practices

  • Use dedicated database users with minimal required permissions
  • Enable audit logging for production environments
  • Set appropriate row limits to prevent accidental mass operations
  • Restrict sensitive tables using the restrictedTables configuration
  • Use WHERE clause requirements for UPDATE/DELETE operations
  • Regular security reviews of configurations and permissions

Connection String Security

bash
# Use environment variables for sensitive data
export DB_PASSWORD="your_secure_password"
json
{
  "connectionString": "Server=myserver;Database=mydb;User Id=myuser;Password=${DB_PASSWORD};"
}

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

bash
# Clone the repo
git clone https://github.com/yourusername/mcp-ms-sql-server.git
cd mcp-ms-sql-server

# Install dependencies
dotnet restore

# Run tests
dotnet test

# Build and test
dotnet build -c Release

📚 Documentation

🐛 Troubleshooting

Common Issues

Connection Failed

bash
# Test your connection string
dotnet run -- --test-connection --config your-project

Permission Denied

  • Check your database user permissions
  • Verify the allowedSchema configuration
  • Ensure the user has access to the specified schema

Configuration Not Found

  • Verify the configuration file exists in Configurations/
  • Check the MCP_CONFIG_NAME environment variable
  • Ensure the JSON syntax is valid

📄 License

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

🌟 Acknowledgments

📞 Support


Made with ❤️ for the MCP and AI development community

MCP Microsoft SQL ServerのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度MCP Microsoft SQL Serverに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

MCP Microsoft SQL Serverをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. MCP Microsoft SQL ServerのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "mcp-ms-sql-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてMCP Microsoft SQL ServerのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. MCP Microsoft SQL ServerのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
MCP Microsoft SQL Serverを使ってこのタスクを手伝ってもらえますか?
MCP Microsoft SQL Server
はい、読みました。
MCP Microsoft SQL Serverで調べた結果をお伝えします。

よくある質問

MCP Microsoft SQL Server MCPサーバーは何に使いますか?

MCP Microsoft SQL Serverは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでMCP Microsoft SQL Server MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでMCP Microsoft SQL Serverを利用できます。

TypingMindでMCP Microsoft SQL Server MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。MCP Microsoft SQL Serverを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

MCP Microsoft SQL Server MCPをTypingMindに接続するにはどうすればよいですか?

MCP Microsoft SQL ServerはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでMCP Microsoft SQL Server MCPのどのようなツールを利用できますか?

MCP Microsoft SQL ServerはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

MCP Microsoft SQL Server MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。MCP Microsoft SQL Serverで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇