MCP Microsoft SQL Server logo

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.

Publisher0xhubed
Repositorymcp-ms-sql-server
LanguageC#
Forks
9
Stars
11
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    MCP Microsoft SQL Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    11 stars and 9 forks from the linked 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

Use MCP Microsoft SQL Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP Microsoft SQL Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP Microsoft SQL Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP Microsoft SQL Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mcp-ms-sql-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP Microsoft SQL Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP Microsoft SQL Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP Microsoft SQL Server to help me with this task?
MCP Microsoft SQL Server
Sure. I read it.
Here is what I found using MCP Microsoft SQL Server.

Frequently asked questions

What is the MCP Microsoft SQL Server MCP server used for?

MCP Microsoft SQL Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP Microsoft SQL Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP Microsoft SQL Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP Microsoft SQL Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP Microsoft SQL Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP Microsoft SQL Server MCP to TypingMind?

MCP Microsoft SQL Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP Microsoft SQL Server MCP provide in TypingMind?

MCP Microsoft SQL Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP Microsoft SQL Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP Microsoft SQL Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇