Labsco
0xhubed logo

MCP Microsoft SQL Server

โ˜… 7

from 0xhubed

An MCP server for integrating with Microsoft SQL Server databases.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

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

๐Ÿ› ๏ธ 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

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

๐Ÿค Contributing

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

Development Setup

# 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

๐Ÿ“„ 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