MSSQL MCP Server
A Model Context Protocol (MCP) server that provides read-only access to Microsoft SQL Server databases using Windows Authentication.
Built for environments where:
π Windows Authentication is required (no username/password storage)
π‘οΈ Read-only access is mandated by IT security policy
π₯οΈ SQL Server is accessed from Windows workstations
π€ AI assistants need safe database access (Claude Code, etc.)
Features
Windows Authentication - Uses
Trusted_Connectionvia pyodbc, no credentials to manageRead-only by design - Only SELECT queries allowed, dangerous keywords blocked
Row limiting - Prevents accidental large result sets (configurable, max 1000)
Schema exploration - List tables, views, describe columns, find relationships
MCP compatible - Works with Claude Code, Claude Desktop, and any MCP client
Available Tools
Tool | Description |
| List all tables in the database, optionally filtered by schema |
| List all views in the database, optionally filtered by schema |
| Get column definitions for a specific table |
| Find foreign key relationships for a table |
| Execute a SELECT query (with security filtering) |
Installation
Prerequisites
Python 3.10+
Windows with ODBC Driver 17+ for SQL Server
Network access to your SQL Server
Windows domain account with SELECT permissions on target database
Install from PyPI (Coming Soon)
Install from Source
Install ODBC Driver (if needed)
Download and install Microsoft ODBC Driver 17 for SQL Server.
Configuration
Environment Variables
Variable | Default | Description |
|
| SQL Server hostname or IP |
|
| Target database name |
|
| ODBC driver name |
Claude Code Configuration
Add to your ~/.claude.json (or %USERPROFILE%\.claude.json on Windows):
Alternative: Direct script execution
Note for Windows users: The
cmd /cwrapper is required for proper stdio communication with MCP clients on Windows.
Claude Desktop Configuration
Add to your Claude Desktop config (%APPDATA%\Claude\claude_desktop_config.json):
Usage Examples
Once configured, you can ask Claude to:
Explore Schema
Query Data
Analyze Relationships
Security
This server is designed with security as a primary concern:
Read-Only Enforcement
Only queries starting with
SELECTare allowedDangerous keywords are blocked even in subqueries:
INSERT,UPDATE,DELETE,DROP,CREATE,ALTEREXEC,EXECUTE,TRUNCATE,GRANT,REVOKE,DENYBACKUP,RESTORE,SHUTDOWN,DBCC
Windows Authentication
Uses
Trusted_Connection=yes- no passwords stored or transmittedLeverages existing Windows domain security
Your database permissions are enforced by SQL Server
Row Limiting
Default limit: 100 rows per query
Maximum limit: 1000 rows per query
Prevents accidental retrieval of large datasets
Development
Running Tests
Running Locally
Troubleshooting
"ODBC Driver not found"
Install the Microsoft ODBC Driver for SQL Server:
"Login failed" or "Cannot connect"
Verify your Windows account has access to the SQL Server
Test connection with
sqlcmd -S your-server -d your-database -ECheck firewall allows connection on port 1433
"Tools not appearing in Claude Code"
Ensure
type: "stdio"is in your configUse the
cmd /cwrapper on WindowsRestart Claude Code after config changes
Check Claude Code logs for MCP errors
Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Submit a pull request
License
MIT License - see LICENSE file.
Acknowledgments
Built with FastMCP for MCP protocol handling
Uses pyodbc for SQL Server connectivity
Inspired by the need for safe AI access to enterprise databases