A powerful Microsoft SQL Server MCP (Model Context Protocol) server that enables Claude Desktop to interact with SQL Server databases through natural language queries. - ๐ค AI-Ready: Seamless integration with Claude Desktop and MCP protocol - ๐ Smart Queries: Execute SQL queries in CSV or JSON format through natural language - ๐ Secure Authentication: Support for SQL Server Auth, Windows Auth, a
Add this skill
npx mdskills install wenerme/wodeWell-documented MCP server enabling SQL Server database queries through Claude with strong security options
1# @wener/mssql-mcp23A powerful Microsoft SQL Server MCP (Model Context Protocol) server that enables Claude Desktop to interact with SQL Server databases through natural language queries.45[](https://www.npmjs.com/package/@wener/mssql-mcp)6[](https://nodejs.org/)78## ๐ Quick Start910### Install and Run with npx (Recommended)1112```bash13# Run directly without installation14npx @wener/mssql-mcp --help1516# Start with environment variables17MSSQL_SERVER=localhost MSSQL_DATABASE=mydb MSSQL_USER=sa MSSQL_PASSWORD=password npx @wener/mssql-mcp --stdio1819# Start with environment file20npx @wener/mssql-mcp --env-file .env --stdio21```2223### Global Installation2425```bash26# Install globally27npm install -g @wener/mssql-mcp2829# Run from anywhere30mssql-mcp --help31```3233## โจ Features3435- ๐ค **AI-Ready**: Seamless integration with Claude Desktop and MCP protocol36- ๐ **Smart Queries**: Execute SQL queries in CSV or JSON format through natural language37- ๐ **Secure Authentication**: Support for SQL Server Auth, Windows Auth, and Azure SQL38- ๐ข **Enterprise Ready**: LocalDB, Azure SQL Database, and SQL Server 2008+ support39- ๐ **Data Access**: Browse database tables and their contents automatically40- ๐ **Zero Config**: Single executable with all dependencies bundled41- ๐ก๏ธ **Read-Only Mode**: Optional safety mode for production databases4243## ๐๏ธ Setup for Claude Desktop4445### 1. Create Environment File4647Create a `.env` file with your database credentials:4849```bash50# Required: Database connection51MSSQL_SERVER=localhost52MSSQL_DATABASE=AdventureWorks201953MSSQL_USER=sa54MSSQL_PASSWORD=YourPassword1235556# Optional: Security and performance57MSSQL_ACCESS_MODE=readonly # Use 'readonly' for safe querying58MSSQL_ENCRYPT=false # Set 'true' for Azure SQL59```6061### 2. Configure Claude Desktop6263Add to your `claude_desktop_config.json`:6465```json66{67 "mcpServers": {68 "mssql": {69 "command": "npx",70 "args": ["@wener/mssql-mcp", "--env-file", "/path/to/your/.env", "--stdio"]71 }72 }73}74```7576### 3. Restart Claude Desktop7778Your SQL Server database is now available to Claude! ๐7980## ๐ Environment Configuration8182### SQL Server Authentication8384```bash85MSSQL_SERVER=localhost86MSSQL_DATABASE=your_database87MSSQL_USER=your_username88MSSQL_PASSWORD=your_password89```9091### Windows Authentication9293```bash94MSSQL_SERVER=localhost95MSSQL_DATABASE=your_database96MSSQL_WINDOWS_AUTH=true97```9899### Azure SQL Database100101```bash102MSSQL_SERVER=yourserver.database.windows.net103MSSQL_DATABASE=your_database104MSSQL_USER=your_username105MSSQL_PASSWORD=your_password106# MSSQL_ENCRYPT=true (automatically enabled for Azure SQL)107```108109### LocalDB110111```bash112MSSQL_SERVER=(localdb)\\MSSQLLocalDB113MSSQL_DATABASE=MyLocalDatabase114MSSQL_WINDOWS_AUTH=true115```116117### Advanced Options118119```bash120# Port (default: 1433)121MSSQL_PORT=1433122123# Force encryption (default: false, auto-enabled for Azure SQL)124MSSQL_ENCRYPT=true125126# Access mode: 'readonly' or 'readwrite' (default: readwrite)127MSSQL_ACCESS_MODE=readonly128```129130## ๐ ๏ธ Available Tools131132When connected, Claude can use these capabilities:133134### ๐ SQL Query Execution135136- **`exec_sql_csv`**: Execute SQL queries and get results in CSV format137- **`exec_sql_json`**: Execute SQL queries and get results in JSON format138- **`get_version`**: Get SQL Server version information _(readOnlyHint: true)_139140### ๐ Database Resources141142- **Table Discovery**: Automatically lists all available tables143- **Table Data Access**: Browse table contents (top 100 rows per table)144- **Schema Information**: Access table structures and metadata145146## ๐ก๏ธ Security Features147148### Read-Only Mode149150For production databases, use read-only mode:151152```bash153MSSQL_ACCESS_MODE=readonly154```155156This restricts operations to:157- `SELECT` statements158- `WITH` (Common Table Expressions)159- `SHOW`, `DESCRIBE`, `EXPLAIN`, `DESC` commands160161### Built-in Protection162163- โ SQL injection prevention through parameterized queries164- โ Table name validation and escaping165- โ Connection encryption for Azure SQL (auto-detected)166- โ Secure credential handling167168## ๐ฏ Usage Examples169170### Ask Claude to Query Your Database171172> "Show me the top 10 customers by total sales from the database"173174> "What tables are available in this database?"175176> "Create a summary report of inventory levels by category"177178> "Find all orders placed in the last 30 days"179180Claude will automatically:1811. ๐ Explore available tables1822. ๐ Write appropriate SQL queries1833. ๐ Execute queries and format results1844. ๐ Analyze and explain the data185186## ๐ Command Line Usage187188### STDIO Mode (Claude Desktop)189190```bash191mssql-mcp --stdio --env-file .env192```193194### HTTP Mode (Development)195196```bash197mssql-mcp --port 3003 --host localhost --env-file .env198```199200### Command Options201202- `--stdio`: Use STDIO transport (required for Claude Desktop)203- `--env-file <path>`: Load environment variables from file204- `--port <port>`: HTTP server port (default: 3003)205- `--host <host>`: HTTP server host (default: localhost)206- `--verbose`: Enable detailed logging207- `--help`: Show help information208209## ๐ง Troubleshooting210211### Connection Issues212213```bash214# Test connection215mssql-mcp --verbose --env-file .env216217# Check SQL Server is running218sqlcmd -S localhost -U sa -P yourpassword -Q "SELECT @@VERSION"219```220221### Common Problems222223**"Login failed"**: Check username, password, and database name224**"Server not found"**: Verify `MSSQL_SERVER` and `MSSQL_PORT`225**"SSL error"**: Set `MSSQL_ENCRYPT=false` for local development226**"Permission denied"**: Ensure user has database access permissions227228### Debug Mode229230```bash231# Enable verbose logging232mssql-mcp --verbose --stdio --env-file .env233```234235## ๐ Example Databases236237### AdventureWorks (Learning)238239Perfect for testing and learning:2402411. Download [AdventureWorks backup files](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks)2422. Restore to your SQL Server instance2433. Configure connection:244245```bash246MSSQL_SERVER=localhost247MSSQL_DATABASE=AdventureWorks2019248MSSQL_USER=sa249MSSQL_PASSWORD=YourPassword123250MSSQL_ACCESS_MODE=readonly # Safe for exploration251```252253### Northwind (Classic)254255Great for business scenarios:256257```bash258MSSQL_SERVER=localhost259MSSQL_DATABASE=Northwind260MSSQL_USER=sa261MSSQL_PASSWORD=YourPassword123262```263264## ๐ข Enterprise Features265266- **SQL Server 2008+ Compatibility**: Works with legacy systems267- **Connection Pooling**: Automatic connection management268- **High Availability**: Supports SQL Server clusters and availability groups269- **Multi-Database**: Connect to different databases by changing configuration270- **Audit Trail**: All queries are logged for security compliance271272## ๐ License273274MIT License - feel free to use in personal and commercial projects.275276## ๐ค Contributing277278Issues and feature requests are welcome on [GitHub](https://github.com/wenerme/wode).279280## ๐ Related Projects281282- [Model Context Protocol](https://modelcontextprotocol.io/) - The protocol specification283- [Claude Desktop](https://claude.ai/download) - AI assistant with MCP support284- [Microsoft SQL Server](https://www.microsoft.com/sql-server/) - Database platform285286---287288**Made with โค๏ธ for the AI and SQL Server community**289
Full transparency โ inspect the skill content before installing.