Logo vun MCP Microsoft SQL Server

MCP Microsoft SQL Server

Communautéit
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.

Editeur0xhubed
Repositorymcp-ms-sql-server
SproochC#
Forks
9
Stären
11
Disponibel Tools
0
Transporttypstdio
Kategorien
Linken
  • Tools mat KI-Workflows verbannen

    MCP Microsoft SQL Server stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    11 Stären an 9 Forks aus dem verlinkte Repository.

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 mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal MCP Microsoft SQL Server verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

MCP Microsoft SQL Server als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu MCP Microsoft SQL Server an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "mcp-ms-sql-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu MCP Microsoft SQL Server. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu MCP Microsoft SQL Server.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat MCP Microsoft SQL Server?
MCP Microsoft SQL Server
Jo. Ech hunn et gelies.
Dat hunn ech mat MCP Microsoft SQL Server fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server MCP Microsoft SQL Server benotzt?

MCP Microsoft SQL Server ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech MCP Microsoft SQL Server MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir MCP Microsoft SQL Server mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat MCP Microsoft SQL Server MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann MCP Microsoft SQL Server verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech MCP Microsoft SQL Server MCP mat TypingMind?

MCP Microsoft SQL Server leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt MCP Microsoft SQL Server MCP an TypingMind zur Verfügung?

MCP Microsoft SQL Server stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir MCP Microsoft SQL Server MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann MCP Microsoft SQL Server eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇