MSSQL MCP Server
MSSQL MCP Server is a Model Context Protocol (MCP) server that enables secure and structured interaction with Microsoft SQL Server (MSSQL) databases. It allows AI assistants to:
- List available tables
- Read table contents
- Execute SQL queries with controlled access
This ensures safer database exploration, strict permission enforcement, and logging of database interactions.
Features
- Secure MSSQL Database Access through environment variables
- Controlled Query Execution with error handling
- Table Listing & Data Retrieval
- Comprehensive Logging for monitoring queries and operations
Installation
1pip install mssql-mcp-server
Configuration
Set the following environment variables to configure database access:
1MSSQL_DRIVER=mssql_driver 2MSSQL_HOST=localhost 3MSSQL_USER=your_username 4MSSQL_PASSWORD=your_password 5MSSQL_DATABASE=your_database
Usage
With Claude Desktop
To integrate with Claude Desktop, add this configuration to claude_desktop_config.json
:
1{ 2 "mcpServers": { 3 "mssql": { 4 "command": "uv", 5 "args": [ 6 "--directory", 7 "path/to/mssql_mcp_server", 8 "run", 9 "mssql_mcp_server" 10 ], 11 "env": { 12 "MSSQL_DRIVER": "mssql_driver", 13 "MSSQL_HOST": "localhost", 14 "MSSQL_USER": "your_username", 15 "MSSQL_PASSWORD": "your_password", 16 "MSSQL_DATABASE": "your_database" 17 } 18 } 19 } 20}
Running as a Standalone Server
1# Install dependencies 2pip install -r requirements.txt 3 4# Run the server 5python -m mssql_mcp_server
Development
1# Clone the repository 2git clone https://github.com/yourusername/mssql_mcp_server.git 3cd mssql_mcp_server 4 5# Set up a virtual environment 6python -m venv venv 7source venv/bin/activate # On Windows: venv\Scripts\activate 8 9# Install development dependencies 10pip install -r requirements-dev.txt 11 12# Run tests 13pytest
Security Considerations
- Use a dedicated MSSQL user with minimal privileges.
- Never use root credentials or full administrative accounts.
- Restrict database access to only necessary operations.
- Enable logging and auditing for security monitoring.
- Regularly review permissions to ensure least privilege access.
Security Best Practices
For a secure setup:
- Create a dedicated MSSQL user with restricted permissions.
- Avoid hardcoding credentials—use environment variables instead.
- Restrict access to necessary tables and operations only.
- Enable SQL Server logging and monitoring for auditing.
- Review database access regularly to prevent unauthorized access.
For detailed instructions, refer to the MSSQL Security Configuration Guide.
⚠️ IMPORTANT: Always follow the Principle of Least Privilege when configuring database access.
License
This project is licensed under the MIT License. See the LICENSE
file for details.
Contributing
We welcome contributions! To contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request.
Need Help?
For any questions or issues, feel free to open a GitHub Issue or reach out to the maintainers.