π¦
Mssql Fastmcp Server
A Model Context Protocol (MCP) server for Microsoft SQL Server that enables secure database interactions through a controlled interface. Allows AI assistants to safely list tables, read data, and execute SQL queries while maintaining security and structure.
0 installs
Trust: 34 β Low
Science
Ask AI about Mssql Fastmcp Server
Powered by Claude Β· Grounded in docs
I know everything about Mssql Fastmcp Server. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
Microsoft SQL Server MCP Server
A Model Context Protocol (MCP) server for secure SQL Server database access through Claude Desktop, built with FastMCP 2.9.2 for modern async performance and enhanced developer experience.
β¨ Key Features
- π Database Discovery: List tables, schemas, and databases
- π SQL Execution: Execute queries with proper validation and security
- π Multi-Auth Support: SQL, Windows, and Azure AD authentication
- π’ Platform Support: LocalDB, SQL Server Express, and Azure SQL
- β‘ Async Performance: Built on FastMCP 2.9.2 with async/await patterns
- π‘οΈ Security First: SQL injection prevention and query validation
- π Rich Resources: Discoverable table schemas and data resources
- π Flexible Configuration: Environment-based configuration with validation
π Tools & Resources
Tools
execute_sql- Execute SQL queries with validation and loggingget_table_schema- Retrieve detailed table schema informationlist_databases- Enumerate available databases on the server
Resources
mssql://tables- List all available tablesmssql://table/{table_name}- Get specific table data and schema
Quick Start
Install with Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mssql": {
"command": "uvx",
"args": ["microsoft_sql_server_mcp"],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_DATABASE": "your_database",
"MSSQL_USER": "your_username",
"MSSQL_PASSWORD": "your_password"
}
}
}
}
Configuration
Basic SQL Authentication
MSSQL_SERVER=localhost # Required
MSSQL_DATABASE=your_database # Required
MSSQL_USER=your_username # Required for SQL auth
MSSQL_PASSWORD=your_password # Required for SQL auth
Windows Authentication
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true # Use Windows credentials
Azure SQL Database
MSSQL_SERVER=your-server.database.windows.net
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Encryption is automatic for Azure
Optional Settings
MSSQL_PORT=1433 # Custom port (default: 1433)
MSSQL_ENCRYPT=true # Force encryption
Alternative Installation Methods
Using pip
pip install microsoft_sql_server_mcp
Then in claude_desktop_config.json:
{
"mcpServers": {
"mssql": {
"command": "python",
"args": ["-m", "mssql_mcp_server"],
"env": { ... }
}
}
}
π§ Development & Testing
Running Tests
# Run refactoring validation tests
python test_refactor.py
# Run full test suite
python -m pytest tests/
Example Usage
# Copy example environment file
cp .env.example .env
# Edit configuration
nano .env
# Run example usage script
python example_usage.py
π‘οΈ Security Best Practices
- Dedicated User: Create a dedicated SQL user with minimal permissions
- No Admin Access: Never use admin/sa accounts in production
- Windows Auth: Use Windows Authentication when possible
- Encryption: Enable encryption for sensitive data connections
- Query Validation: All queries are validated against injection patterns
- Secure Logging: Sensitive data is masked in logs
ποΈ Architecture
This server is built with:
- FastMCP 2.9.2: Modern async MCP framework with context injection
- Pydantic V2: Configuration validation and data modeling
- Thread Pool: Async wrapper for synchronous pymssql operations
- Security Layer: SQL injection prevention and query validation
- Comprehensive Logging: Detailed logging with context awareness
π License
MIT
