Integrates with Codecov for code coverage reporting and quality metrics.
Offers Docker-ready deployment options for running the MCPQL server in containerized environments.
Hosted on GitHub with CI/CD workflow integration for automated testing and deployment.
Uses Jest for comprehensive testing of all database tools and operations.
Runs on Node.js (18+) as the execution environment for the SQL Server MCP server.
Available as an npm package for easy installation and dependency management.
Built with TypeScript 5.8.3, providing type-safe interactions with SQL Server databases.
MCPQL - SQL Server MCP
A comprehensive Model Context Protocol (MCP) server for SQL Server database operations. This server provides 10 powerful tools for database analysis, object discovery, and data manipulation through the MCP protocol.
🚀 Quick Start
Prerequisites
- Node.js 18+ and npm
- SQL Server database with appropriate connection credentials
- MCP-compatible client (like Claude Desktop, Cursor IDE, or any MCP client)
Installation & Configuration
Option 1: Using npx from GitHub (Recommended)
No installation needed! Just configure your MCP client:
For Claude Desktop (claude_desktop_config.json
):
For Cursor IDE:
Option 2: Local Development Installation
- Clone and setup:
- Configure database connection:
Create a
.env
file with your database credentials:
- Configure MCP client with local path:
🛠️ Available Tools
MCPQL provides 10 comprehensive tools for SQL Server database operations:
1. 🏗️ Table Analysis - mcp_table_analysis
Complete table structure analysis including columns, keys, indexes, and constraints.
2. 📋 Stored Procedure Analysis - mcp_sp_structure
Analyze stored procedure structure including parameters, dependencies, and source code.
3. 👀 Data Preview - mcp_preview_data
Preview table data with optional filtering and row limits.
4. 📊 Column Statistics - mcp_get_column_stats
Get comprehensive statistics for a specific column.
5. ⚙️ Execute Stored Procedure - mcp_execute_procedure
Execute stored procedures with parameters and return results.
6. 🔍 Execute SQL Query - mcp_execute_query
Execute custom SQL queries with full error handling.
7. ⚡ Quick Data Analysis - mcp_quick_data_analysis
Quick statistical analysis including row count, column distributions, and top values.
8. 🔎 Comprehensive Search - mcp_search_comprehensive
Search across database objects by name and definition with configurable criteria.
9. 🔗 Object Dependencies - mcp_get_dependencies
Get dependencies for database objects (tables, views, stored procedures, etc.).
10. 🎯 Sample Values - mcp_get_sample_values
Get sample values from a specific column in a table.
📋 Usage Examples
Analyzing a Table
Finding Database Objects
Analyzing Stored Procedures
Data Analysis
🔧 Environment Variables & Connection Types
MCPQL supports multiple SQL Server connection types with comprehensive configuration options:
🔐 Authentication Types
Set DB_AUTHENTICATION_TYPE
to one of:
sql
- SQL Server Authentication (default)windows
- Windows Authenticationazure-ad
- Azure Active Directory Authentication
📋 Complete Environment Variables
Variable | Description | Default | Required For |
---|---|---|---|
Basic Connection | |||
DB_AUTHENTICATION_TYPE | Authentication type (sql/windows/azure-ad) | sql | All |
DB_SERVER | SQL Server hostname/IP | - | All |
DB_NAME | Database name | - | All |
DB_PORT | SQL Server port | 1433 | All |
DB_TIMEOUT | Connection timeout (ms) | 30000 | All |
DB_REQUEST_TIMEOUT | Request timeout (ms) | 30000 | All |
SQL Server Authentication | |||
DB_USER | SQL Server username | - | SQL Auth |
DB_PASSWORD | SQL Server password | - | SQL Auth |
Windows Authentication | |||
DB_DOMAIN | Windows domain | - | Windows Auth |
DB_USER | Windows username | current user | Windows Auth |
DB_PASSWORD | Windows password | - | Windows Auth |
Azure AD Authentication | |||
DB_USER | Azure AD username | - | Azure AD (Password) |
DB_PASSWORD | Azure AD password | - | Azure AD (Password) |
DB_AZURE_CLIENT_ID | Azure AD App Client ID | - | Azure AD (Service Principal) |
DB_AZURE_CLIENT_SECRET | Azure AD App Client Secret | - | Azure AD (Service Principal) |
DB_AZURE_TENANT_ID | Azure AD Tenant ID | - | Azure AD (Service Principal) |
SQL Server Express | |||
DB_INSTANCE_NAME | Named instance (e.g., SQLEXPRESS) | - | Express instances |
Security Settings | |||
DB_ENCRYPT | Enable encryption | false | All |
DB_TRUST_SERVER_CERTIFICATE | Trust server certificate | false | All |
DB_ENABLE_ARITH_ABORT | Enable arithmetic abort | true | All |
DB_USE_UTC | Use UTC for dates | true | All |
Connection Pool | |||
DB_POOL_MAX | Maximum connections | 10 | All |
DB_POOL_MIN | Minimum connections | 0 | All |
DB_POOL_IDLE_TIMEOUT | Idle timeout (ms) | 30000 | All |
Advanced Settings | |||
DB_CANCEL_TIMEOUT | Cancel timeout (ms) | 5000 | All |
DB_PACKET_SIZE | Packet size (bytes) | 4096 | All |
DB_CONNECTION_STRING | Complete connection string | - | Alternative to individual settings |
🔧 Connection Configuration Examples
1. 🏠 SQL Server Local (SQL Authentication)
2. 🏢 SQL Server Express (Named Instance)
3. 🪟 Windows Authentication
4. ☁️ Azure SQL Database (Azure AD Password)
5. 🔐 Azure SQL Database (Service Principal)
6. 🔗 Using Connection String
🚨 Troubleshooting Common Issues
Connection Issues
- "Login failed": Check username/password. For Windows auth, ensure
DB_AUTHENTICATION_TYPE=windows
- "Server was not found": Verify server name and port. For SQL Express, add
DB_INSTANCE_NAME
- "Certificate" errors: For local development, set
DB_TRUST_SERVER_CERTIFICATE=true
- Timeout errors: Increase
DB_TIMEOUT
or check network connectivity
SQL Server Express Setup
- Enable TCP/IP protocol in SQL Server Configuration Manager
- Set a static port (usually 1433) or use dynamic port with Browser Service
- Configure Windows Firewall to allow SQL Server traffic
- Use
DB_INSTANCE_NAME=SQLEXPRESS
for default Express installations
Azure SQL Database Setup
- Create server firewall rules to allow client IP
- Use format:
server.database.windows.net
for server name - Always set
DB_ENCRYPT=true
andDB_TRUST_SERVER_CERTIFICATE=false
- For Service Principal auth, register app in Azure AD and assign permissions
🧪 Testing
Run the comprehensive test suite:
The test suite includes comprehensive testing of all 10 tools with real database testing and complete coverage.
🏗️ Architecture
Project Structure
Key Features
- ⚡ Connection Pooling: Efficient database connection management
- 🛡️ Robust Error Handling: Comprehensive error handling and validation
- 📋 Rich Metadata: Detailed results with comprehensive database information
- 🔧 Flexible Configuration: Environment-based configuration
- 📊 Optimized Queries: Efficient SQL queries for all operations
📝 Important Notes
- Object Names: Always use schema-qualified names (e.g.,
dbo.Users
,api.Idiomas
) - Error Handling: All tools return structured responses with success/error indicators
- Type Safety: Full TypeScript support with proper type definitions
- Connection Management: Automatic connection pooling and retry logic
- Security: Parameterized queries to prevent SQL injection
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes and add tests
- Ensure all tests pass (
npm test
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with the Model Context Protocol SDK
- Uses mssql for SQL Server connectivity
- Comprehensive testing with Jest
🏷️ Tags & Keywords
Database: sql-server
azure-sql
database-analysis
database-tools
mssql
t-sql
database-management
database-administration
database-operations
data-analysis
MCP & AI: model-context-protocol
mcp-server
mcp-tools
ai-tools
claude-desktop
cursor-ide
anthropic
llm-integration
ai-database
intelligent-database
Technology: typescript
nodejs
npm-package
cli-tool
database-client
sql-client
database-sdk
rest-api
json-api
database-connector
Features: table-analysis
stored-procedures
data-preview
column-statistics
query-execution
database-search
object-dependencies
schema-analysis
data-exploration
database-insights
Deployment: docker
azure-deployment
cloud-ready
enterprise-ready
production-ready
scalable
secure
authenticated
encrypted
configurable
Use Cases: database-development
data-science
business-intelligence
database-migration
schema-documentation
performance-analysis
data-governance
database-monitoring
troubleshooting
automation
🎯 MCPQL provides comprehensive SQL Server database analysis and manipulation capabilities through the Model Context Protocol. Perfect for database administrators, developers, and anyone working with SQL Server databases! 🚀
This server cannot be installed
A comprehensive Model Context Protocol server for SQL Server database operations that provides 10 powerful tools for database analysis, object discovery, and data manipulation.
- 🚀 Quick Start
- 🛠️ Available Tools
- 1. 🏗️ Table Analysis - mcp_table_analysis
- 2. 📋 Stored Procedure Analysis - mcp_sp_structure
- 3. 👀 Data Preview - mcp_preview_data
- 4. 📊 Column Statistics - mcp_get_column_stats
- 5. ⚙️ Execute Stored Procedure - mcp_execute_procedure
- 6. 🔍 Execute SQL Query - mcp_execute_query
- 7. ⚡ Quick Data Analysis - mcp_quick_data_analysis
- 8. 🔎 Comprehensive Search - mcp_search_comprehensive
- 9. 🔗 Object Dependencies - mcp_get_dependencies
- 10. 🎯 Sample Values - mcp_get_sample_values
- 📋 Usage Examples
- 🔧 Environment Variables & Connection Types
- 🔧 Connection Configuration Examples
- 🚨 Troubleshooting Common Issues
- 🧪 Testing
- 🏗️ Architecture
- 📝 Important Notes
- 🤝 Contributing
- 📄 License
- 🙏 Acknowledgments
- 🏷️ Tags & Keywords
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that enables secure and structured interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries with controlled access.Last updated -39PythonMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.Last updated -JavaScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -1185PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables executing SQL queries and managing connections with Microsoft SQL Server databases.Last updated -1425TypeScriptMIT License