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.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCPQLshow me the top 10 customers by total purchase amount"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 (
For Cursor IDE:
Option 2: Local Development Installation
Clone and setup:
Configure database connection: Create a
.envfile with your database credentials:
Configure MCP client with local path:
Related MCP server: MySQL-MCP
🛠️ Available Tools
MCPQL provides 11 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.
11. 🔒 Security Status - mcp_get_security_status
Get current security configuration and status for database operations.
📋 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 | |||
| Authentication type (sql/windows/azure-ad) | sql | All |
| SQL Server hostname/IP | - | All |
| Database name | - | All |
| SQL Server port | 1433 | All |
| Connection timeout (ms) | 30000 | All |
| Request timeout (ms) | 30000 | All |
SQL Server Authentication | |||
| SQL Server username | - | SQL Auth |
| SQL Server password | - | SQL Auth |
Windows Authentication | |||
| Windows domain | - | Windows Auth |
| Windows username | current user | Windows Auth |
| Windows password | - | Windows Auth |
Azure AD Authentication | |||
| Azure AD username | - | Azure AD (Password) |
| Azure AD password | - | Azure AD (Password) |
| Azure AD App Client ID | - | Azure AD (Service Principal) |
| Azure AD App Client Secret | - | Azure AD (Service Principal) |
| Azure AD Tenant ID | - | Azure AD (Service Principal) |
SQL Server Express | |||
| Named instance (e.g., SQLEXPRESS) | - | Express instances |
Security Settings | |||
| Enable encryption | false | All |
| Trust server certificate | false | All |
| Enable arithmetic abort | true | All |
| Use UTC for dates | true | All |
Connection Pool | |||
| Maximum connections | 10 | All |
| Minimum connections | 0 | All |
| Idle timeout (ms) | 30000 | All |
Advanced Settings | |||
| Cancel timeout (ms) | 5000 | All |
| Packet size (bytes) | 4096 | All |
| Complete connection string | - | Alternative to individual settings |
Security Controls | |||
| Allow DML/DDL operations | false | All |
| Allow stored procedure execution | false | All |
🔧 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
🔒 Security Features
MCPQL includes comprehensive security controls to prevent accidental database modifications, especially important in production environments.
🛡️ Security Controls
Database Modification Protection
DB_ALLOW_MODIFICATIONS: Controls DML/DDL operations (INSERT, UPDATE, DELETE, ALTER, DROP, CREATE)DB_ALLOW_STORED_PROCEDURES: Controls stored procedure executionDefault: Both variables default to
falsefor maximum security
Security Status Tool
Use mcp_get_security_status to check current security configuration:
🔧 Enabling Operations
For Development Environment
For Production Environment (Recommended)
🚨 Security Error Messages
When operations are blocked, MCPQL provides clear guidance:
📋 Always Allowed Operations
These operations are always permitted regardless of security settings:
SELECT queries
Table analysis and schema inspection
Column statistics and data preview
Object search and dependency analysis
Database metadata operations
For complete security documentation, see SECURITY.md.
🚨 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=trueTimeout errors: Increase
DB_TIMEOUTor 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=SQLEXPRESSfor default Express installations
Azure SQL Database Setup
Create server firewall rules to allow client IP
Use format:
server.database.windows.netfor server nameAlways set
DB_ENCRYPT=trueandDB_TRUST_SERVER_CERTIFICATE=falseFor 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! 🚀