MCP Microsoft SQL Server
About
An MCP server for integrating with Microsoft SQL Server databases.
Details
- Author
- 0xhubed
- Categories
- Database, Other
- Tags
- #sql
Jump to
Setup
Install MCP Microsoft SQL Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/0xhubed/mcp-ms-sql-server
Follow the installation instructions in the repository README, then restart your MCP client.
An MCP server for integrating with Microsoft SQL Server databases.
A configurableModel Context Protocol (MCP) serverfor 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.
- 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
- 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
- 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
- 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
- .NET 9.0 or later
- Microsoft SQL Server(any supported version)
- Claude Desktop(for Claude integration)
- Appropriate database permissionsfor the operations you want to perform
# 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
Create a configuration file for your project in theConfigurations/directory:
// 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 } }
Add to your Claude Desktop configuration:
Windows:%APPDATA%\Claude\claude_desktop_config.jsonmacOS:~/Library/Application Support/Claude/claude_desktop_config.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 withdotnet build -c Releaseto create the executable.
- "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"
{ "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"] }
{ "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 } }
{ "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"] }
- ListConfigurations- Show all available project configurations
- SwitchConfiguration- Switch to a different project configuration
- GetCurrentConfiguration- View current configuration details
- TestConnection- Test database connectivity
- 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)
- 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
- Use dedicated database userswith minimal required permissions
- Enable audit loggingfor production environments
- Set appropriate row limitsto prevent accidental mass operations
- Restrict sensitive tablesusing therestrictedTablesconfiguration
- Use WHERE clause requirementsfor UPDATE/DELETE operations
- Regular security reviewsof configurations and permissions
# Use environment variables for sensitive data export DB_PASSWORD="your_secure_password"
{ "connectionString": "Server=myserver;Database=mydb;User Id=myuser;Password=${DB_PASSWORD};" }
We welcome contributions! Please see ourContributing Guidefor details.
# 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
- Configuration Guide
- Claude Desktop Setup
- Security Best Practices
- API Reference
- Troubleshooting
# Test your connection string dotnet run -- --test-connection --config your-project
- Check your database user permissions
- Verify theallowedSchemaconfiguration
- Ensure the user has access to the specified schema
- Verify the configuration file exists inConfigurations/
- Check theMCP_CONFIG_NAMEenvironment variable
- Ensure the JSON syntax is valid
This project is licensed under the MIT License - see theLICENSEfile for details.
- Model Context Protocolby Anthropic
- MCP C# SDKby Microsoft and Anthropic
- The open-source community for inspiration and feedback
- Issues:GitHub Issues
- Discussions:GitHub Discussions
- Documentation:Wiki
Made with ❤️ for the MCP and AI development community
Official MCP server for dbt (data build tool) providing integration with dbt Core/Cloud CLI, project metadata discovery, model information, and semantic layer querying capabilities.
Open source MCP server specializing in easy, fast, and secure tools for Databases.
Query and analyze data with MotherDuck and local DuckDB
Query Streams securely connects MCP clients to live databases through the Query Streams Cloud Network, with no VPNs, inbound ports, or complex setup.
Interact with the SingleStore database platform
Official Supabase MCP server for managing Supabase projects, databases, auth, storage, edge functions, and SQL workflows from AI agents.
A collection of tools for managing the platform, addressing data quality and reading and writing to Teradata Database.
Multi-database agent access (PostgreSQL, SQLite, MySQL, Oracle, SQL Server) with batch queries, pre-configured connections, and SQLGlot-enforced read-only safety
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





