Logo di MCP Microsoft SQL Server

MCP Microsoft SQL Server

Community
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.

Autore0xhubed
Repositorymcp-ms-sql-server
LinguaC#
Fork
9
Stelle
11
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
Link
  • Collega gli strumenti ai flussi di lavoro IA

    MCP Microsoft SQL Server mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    11 stelle e 9 fork nel repository collegato.

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

Usa MCP MCP Microsoft SQL Server con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso MCP Microsoft SQL Server, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi MCP Microsoft SQL Server come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di MCP Microsoft SQL Server.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "mcp-ms-sql-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di MCP Microsoft SQL Server, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di MCP Microsoft SQL Server.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare MCP Microsoft SQL Server per aiutarmi con questa attività?
MCP Microsoft SQL Server
Certo. Ho letto.
Ecco cosa ho trovato con MCP Microsoft SQL Server.

Domande frequenti

A cosa serve il server MCP MCP Microsoft SQL Server?

MCP Microsoft SQL Server è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare MCP Microsoft SQL Server MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare MCP Microsoft SQL Server con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP MCP Microsoft SQL Server con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando MCP Microsoft SQL Server, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego MCP Microsoft SQL Server MCP a TypingMind?

MCP Microsoft SQL Server funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre MCP Microsoft SQL Server MCP in TypingMind?

MCP Microsoft SQL Server mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare MCP Microsoft SQL Server MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se MCP Microsoft SQL Server richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇