MSSQL Database MCP Server
Enables AI assistants to securely interact with Microsoft SQL Server databases to query data, inspect schemas, and retrieve metadata with read-only operations by default and optional write capabilities.
README
MSSQL Database MCP Server
An enterprise-grade Model Context Protocol (MCP) server for Microsoft SQL Server. This server enables AI assistants (like Claude, Cursor, Windsurf) to securely interact with MSSQL databases to query data, inspect schemas, and retrieve metadata.
Features
- Read-Only by Default: Strict safety controls to prevent accidental writes.
- Schema Introspection: Tools to list databases, tables, and describe table schemas.
- Secure Authentication: Supports SQL Server authentication with encryption.
- Docker Ready: Easy deployment using Docker or Docker Compose.
- Comprehensive Logging: Structured JSON logging for auditing.
Quick Start
1. Build the Docker Image
docker build -t mssql-mcp-server:latest .
2. Configure Environment
Create a .env file based on .env.example:
cp .env.example .env
Edit .env with your MSSQL connection details:
MSSQL_HOST=host.docker.internal
MSSQL_PORT=1433
MSSQL_DATABASE=master
MSSQL_USER=sa
MSSQL_PASSWORD=YourStrong@Passw0rd
MSSQL_ENCRYPT=true
MSSQL_TRUST_SERVER_CERTIFICATE=true
3. Run with Docker Compose
docker-compose up -d
Tools Available
The server exposes the following MCP tools:
Core Tools (Always Available)
mssql_query: Execute SELECT queries (with safety checks)mssql_list_databases: List all accessible databasesmssql_list_tables: List tables in a specific database/schemamssql_describe_table: Get detailed schema information (columns, PKs) for a tablemssql_pool_stats: Get connection pool statistics for monitoring
Advanced Tools (Require Write Operations Enabled)
⚠️ These tools require MSSQL_ALLOW_WRITE_OPERATIONS=true
mssql_execute_procedure: Execute stored procedures with parametersmssql_execute_write: Execute INSERT, UPDATE, DELETE statements with transaction safety
Performance Features
Connection Pooling
The server implements intelligent connection pooling for optimal performance:
- Reusable Connections: Connections are pooled and reused across queries
- Thread-Safe: Safe for concurrent requests
- Auto-Validation: Connections are validated before use
- Configurable Limits: Control min/max pool size via environment variables
- Connection Lifetime: Automatic rotation of long-lived connections
- Monitoring: Track pool usage with
mssql_pool_statstool
Configuration:
MIN_POOL_SIZE=2 # Minimum connections to maintain
MAX_POOL_SIZE=10 # Maximum concurrent connections
IDLE_TIMEOUT=300 # Seconds before idle connection closes
CONNECTION_LIFETIME=1800 # Max lifetime of a connection (30 min)
Monitor Pool Health:
{
"total_connections": 5,
"available_connections": 3,
"max_connections": 10,
"min_connections": 2
}
IDE Integration
For detailed integration instructions for Claude Desktop, Cursor, and Windsurf, see IDE-INTEGRATION.md.
Example Configuration (Generic)
Add this to your IDE's MCP configuration file:
{
"mcpServers": {
"mssql": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network", "host",
"-e", "MSSQL_HOST=localhost",
"-e", "MSSQL_USER=sa",
"-e", "MSSQL_PASSWORD=password",
"mssql-mcp-server:latest"
]
}
}
}
Development & Testing
The project includes an automated test suite that spins up a test MSSQL container.
Run Tests
# Make scripts executable
chmod +x test-runner.sh
# Run full integration test suite
./test-runner.sh
Project Structure
src/: Source codeserver.py: Main MCP server entry pointtools/: MCP tool implementationsdatabase/: Database connection and validation logic
tests/: Integration testsdocker/: Docker configuration
Security Notes
- Write Operations: Disabled by default. To enable, set
MSSQL_ALLOW_WRITE_OPERATIONS=true. - Credentials: Never commit
.envfiles. Use Docker secrets in production. - Network: Use TLS (
MSSQL_ENCRYPT=true) for non-local connections.
Support This Project
If you find this MSSQL MCP Server useful for your projects, please consider supporting its development!
☕ Become a Patron
This project is maintained by independent developers. Your support helps us:
- 🚀 Add new features and improvements
- 🐛 Fix bugs and improve stability
- 📚 Create better documentation and tutorials
- 🔒 Enhance security features
- 🎯 Provide faster support and updates
Supporter Benefits
Patrons get access to:
- 🎯 Priority Support - Get help faster when you need it
- 📝 Early Access - Try new features before public release
- 💬 Direct Communication - Influence the project roadmap
- 🎓 Exclusive Tutorials - Advanced usage guides and examples
- 🏆 Recognition - Your name in our SUPPORTERS.md file
Other Ways to Support
- ⭐ Star this repository on GitHub
- 🐛 Report bugs and request features via GitHub Issues
- 📖 Improve documentation by submitting pull requests
- 💬 Spread the word - Share with colleagues and on social media
License
This project is licensed under the MIT License - see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。