Skip to main content
Glama
SMOKE-TEST-GUIDE.mdβ€’20.4 kB
# SQL Server MCP Testing Guide ## Overview This guide provides comprehensive testing procedures for the SQL Server MCP server, covering **automated**, **manual**, and **protocol-level** testing approaches. The MCP server has been **fully validated** through 610+ tests across all testing layers. **βœ… Production Status**: This MCP server has been **comprehensively tested and validated** with 100% success rates across all security phases. ## Purpose - **Verify Core Functionality**: Ensure all database operations work as expected - **Validate Security**: Confirm the three-tier safety system is properly enforced - **Identify Issues**: Detect any connectivity, configuration, or functionality problems - **Production Readiness**: Assess production deployment readiness - **Multiple Test Approaches**: Automated, manual, and protocol-level validation ## Testing Approaches ### πŸš€ **Quick Testing (Automated)** ```bash # Run all automated tests (unit + integration) npm test # Run with coverage npm run test:coverage ``` ### πŸ”§ **Comprehensive Testing (Manual)** ```bash # Test all three security phases (40 tests) npm run test:integration:manual # Note: Individual phase tests are run sequentially within test:integration:manual # Phase 1: 20 tests - Read-only security # Phase 2: 10 tests - DML operations # Phase 3: 10 tests - DDL operations ``` ### πŸ“‘ **Protocol Testing (MCP Client-Server Communication)** ```bash # Test MCP protocol communication (20 tests) npm run test:integration:protocol ``` ## Prerequisites ### **For Automated Tests** - βœ… **No special setup required** - Uses mocked databases - βœ… **Runs in CI/CD** - No external dependencies ### **For Manual & Protocol Tests** 1. **SQL Server Instance**: Running and accessible 2. **Test Database**: `WarpMcpTest` with sample data (created automatically if missing) 3. **Environment Configuration**: Valid `.env` file or environment variables 4. **SSL Configuration**: Proper certificate trust settings if encryption enabled ## Comprehensive Test Coverage ### πŸ“Š **Test Suite Overview** | Test Type | Count | Purpose | Database | Automation | | ------------------------------ | -------- | ------------------------------ | --------- | ------------ | | **Unit Tests** | 535+ | Code logic validation | Mocked | βœ… Automated | | **Integration Tests (Auto)** | 15 | Component integration | Mocked | βœ… Automated | | **Integration Tests (Manual)** | 40 | Security phase validation | Live DB | ❌ Manual | | **Protocol Tests** | 20 | MCP communication validation | Live DB | ❌ Manual | | **TOTAL** | **610+** | **Complete system validation** | **Mixed** | **Mixed** | ### βœ… **Production Validation Results** - **βœ… Phase 1 (Read-Only)**: 20/20 tests passed - Maximum security validated - **βœ… Phase 2 (DML Operations)**: 10/10 tests passed - Selective permissions validated - **βœ… Phase 3 (DDL Operations)**: 10/10 tests passed - Full development mode validated - **βœ… Protocol Communication**: 20/20 tests passed - MCP client-server validated #### Total: 100% success rate across all manual validation tests ## Manual Testing Categories (For Reference) ### 1. Basic Connectivity and Database Operations **Objective**: Verify basic connection and database enumeration capabilities. **Tests**: - `list_databases` - Should return user databases (excluding system DBs) - `list_tables` - Should list tables in a specified database **Expected Results**: - βœ… Connection established successfully - βœ… Database list returned with proper formatting - βœ… Table list shows correct schema and table information **Sample Commands**: ```json // List all databases {"name": "list_databases", "input": {}} // List tables in specific database {"name": "list_tables", "input": {"database": "WarpMcpTest"}} ``` ### 2. Core Database Schema Operations **Objective**: Test schema inspection and relationship discovery capabilities. **Tests**: - `describe_table` - Get detailed table schema information - `list_foreign_keys` - Discover foreign key relationships **Expected Results**: - βœ… Complete column information (types, nullability, defaults, constraints) - βœ… Primary key identification - βœ… Foreign key relationships properly mapped **Sample Commands**: ```json // Describe table structure {"name": "describe_table", "input": {"database": "WarpMcpTest", "table_name": "Products"}} // List foreign key relationships {"name": "list_foreign_keys", "input": {"database": "WarpMcpTest"}} ``` ### 3. Data Retrieval Operations **Objective**: Verify data access and export functionality. **Tests**: - `get_table_data` - Retrieve sample data with optional filtering - `export_table_csv` - Export data in CSV format **Expected Results**: - βœ… Properly formatted tabular data returned - βœ… CSV export with correct headers and formatting - βœ… Filtering and limiting work correctly **Sample Commands**: ```json // Get sample data {"name": "get_table_data", "input": {"database": "WarpMcpTest", "table_name": "Categories", "limit": 5}} // Export as CSV {"name": "export_table_csv", "input": {"database": "WarpMcpTest", "table_name": "Products", "limit": 3}} ``` ### 4. Query Execution and Analysis **Objective**: Test SQL query execution capabilities. **Tests**: - `execute_query` - Execute arbitrary SQL queries - `explain_query` - Generate execution plans **Expected Results**: - βœ… SELECT queries execute successfully - βœ… Complex JOINs and aggregations work - βœ… `explain_query` now works with proper batch handling **Sample Commands**: ```json // Execute complex query { "name": "execute_query", "input": { "database": "WarpMcpTest", "query": "SELECT TOP 3 p.ProductName, c.CategoryName, p.Price FROM Products p JOIN Categories c ON p.CategoryID = c.CategoryID ORDER BY p.Price DESC" } } // Explain query execution plan { "name": "explain_query", "input": { "database": "WarpMcpTest", "query": "SELECT COUNT(*) FROM Products WHERE CategoryID = 1" } } ``` ### 5. Performance Monitoring Tools **Objective**: Test performance monitoring and health check capabilities. **Tests**: - `get_performance_stats` - Overall performance statistics - `get_query_performance` - Query performance breakdown - `get_connection_health` - Connection pool health **Expected Results**: - βœ… Performance statistics returned in proper JSON format - βœ… Query performance breakdown available - βœ… Connection health metrics accessible **Sample Commands**: ```json // Get performance statistics {"name": "get_performance_stats", "input": {"timeframe": "all"}} // Get query performance {"name": "get_query_performance", "input": {}} // Check connection health {"name": "get_connection_health", "input": {}} ``` ### 6. Query Optimization Tools **Objective**: Test advanced query optimization and analysis features. **Tests**: - `get_index_recommendations` - Index optimization suggestions - `analyze_query_performance` - Deep query analysis - `detect_query_bottlenecks` - Bottleneck detection - `get_optimization_insights` - Comprehensive optimization analysis **Expected Results**: - βœ… Index recommendations returned in structured format - βœ… Query performance analysis available - βœ… Bottleneck detection working - βœ… Optimization insights accessible **Sample Commands**: ```json // Get index recommendations {"name": "get_index_recommendations", "input": {"database": "WarpMcpTest"}} // Analyze query performance { "name": "analyze_query_performance", "input": { "database": "WarpMcpTest", "query": "SELECT * FROM Products WHERE CategoryID = 1" } } // Detect bottlenecks {"name": "detect_query_bottlenecks", "input": {"database": "WarpMcpTest"}} // Get optimization insights {"name": "get_optimization_insights", "input": {"database": "WarpMcpTest"}} ``` ### 7. Security and Safety Boundaries **Objective**: Verify the three-tier safety system is properly enforced. **Tests**: - Test INSERT operations (should be blocked in read-only mode) - Test UPDATE operations (should be blocked in read-only mode) - Test DELETE operations (should be blocked in read-only mode) - Test DDL operations (should be blocked in read-only mode) - Verify SELECT operations work normally **Expected Results**: - πŸ”’ All modification operations blocked with clear error messages - βœ… SELECT queries continue to work normally - βœ… Security policy violations properly reported **Sample Commands**: ```json // These should be BLOCKED in read-only mode {"name": "execute_query", "input": {"database": "WarpMcpTest", "query": "INSERT INTO Categories (CategoryName, Description) VALUES ('Test', 'Test')"}} {"name": "execute_query", "input": {"database": "WarpMcpTest", "query": "UPDATE Products SET Price = 50.00 WHERE ProductID = 1"}} {"name": "execute_query", "input": {"database": "WarpMcpTest", "query": "DELETE FROM Products WHERE ProductID = 99"}} {"name": "execute_query", "input": {"database": "WarpMcpTest", "query": "CREATE TABLE TestTable (ID int PRIMARY KEY, Name nvarchar(100))"}} // This should WORK {"name": "execute_query", "input": {"database": "WarpMcpTest", "query": "SELECT COUNT(*) as ProductCount FROM Products"}} ``` ## Automated Test Execution ### πŸš€ **Recommended Testing Workflow** #### **1. Development Testing** ````bash # Quick validation during development npm test # Run all automated tests ```bash npm run test:coverage # Check code coverage ```` #### **Manual Testing (Live Database)** ````bash npm run test:integration:manual # All 3 security phases (40 tests) npm run test:integration:protocol # MCP protocol validation (20 tests) ```bash # End of previous section ```` #### **2. Pre-Production Validation** ```bash # Comprehensive manual testing before deployment npm run test:integration:manual # All 3 security phases (40 tests) npm run test:integration:protocol # MCP protocol validation (20 tests) ``` #### **3. Production Readiness Check** ````bash # Complete validation suite npm run ci # Full CI pipeline with security audit ```bash npm run test:integration:manual # Manual integration validation npm run test:integration:protocol # Protocol communication validation ```bash # Complete validation suite npm run ci # Full CI pipeline with security audit ``` ### πŸ“‹ **Comprehensive Testing Guides** - **[Manual Integration Tests β†’](../test/integration/manual/README.md)** - Complete guide for manual security phase testing - **[Protocol Tests β†’](../test/protocol/README.md)** - MCP client-server communication testing - **[Unit Tests β†’](../test/README.md)** - Comprehensive unit test documentation ### βœ… **Quick Validation Checklist** #### **Automated Tests (Always Run)** - [ ] **Unit Tests** - `npm test` (535+ tests) - [ ] **Coverage** - `npm run test:coverage` (60%+ coverage) - [ ] **Code Quality** - `npm run ci` (linting, formatting, security) #### **Manual Tests (Pre-Production)** - [ ] **Phase 1-3** - `npm run test:integration:manual` (All security phases) - [ ] **Protocol** - `npm run test:integration:protocol` (MCP communication) ### 🎯 **Using Warp AI Terminal** With Warp MCP integration, you can validate functionality by: 1. **Ask Warp to list databases**: "List all databases on the SQL Server" 2. **Test table operations**: "Show me the structure of the Products table" 3. **Execute queries**: "Get the top 5 products by price" 4. **Export data**: "Export the Categories table as CSV" 5. **Test security**: Try INSERT/UPDATE operations (should be blocked in read-only mode) ## Expected Results Summary ### βœ… **Complete Production Validation Results** #### **All 16 MCP Tools (100% Validated)** | Category | Tool | Status | Validation | | ---------------- | --------------------------- | --------------------------- | ------------------ | --------------- | | **Database** | `list_databases` | βœ… Validated | All test phases | | **Database** | `list_tables` | βœ… Validated | All test phases | | **Schema** | `describe_table` | βœ… Validated | All test phases | | **Schema** | `list_foreign_keys` | βœ… Validated | All test phases | | **Data** | `get_table_data` | βœ… Validated | All test phases | | **Data** | `export_table_csv` | βœ… Validated | All test phases | | **Query** | `execute_query` | βœ… Validated | All security modes | | **Query** | `explain_query` | βœ… Validated | All test phases | | **Performance** | `get_performance_stats` | βœ… Validated | All test phases | | **Performance** | `get_query_performance` | βœ… Validated | All test phases | | **Performance** | `get_connection_health` | βœ… Validated | All test phases | | **Optimization** | `get_index_recommendations` | βœ… Validated | All test phases | | **Optimization** | `analyze_query_performance` | βœ… Validated | All test phases | | **Optimization** | `detect_query_bottlenecks` | βœ… Validated | All test phases | | | **Optimization** | `get_optimization_insights` | βœ… Validated | All test phases | | | **Diagnostics** | `get_server_info` | βœ… Validated | All test phases | #### **Security System (100% Validated)** | Security Level | Configuration | Validation | Status | | -------------- | ----------------- | ----------- | ----------- | | **Phase 1** | Read-Only Mode | 20/20 tests | βœ… **100%** | | **Phase 2** | DML Operations | 10/10 tests | βœ… **100%** | | **Phase 3** | DDL Operations | 10/10 tests | βœ… **100%** | | **Protocol** | MCP Communication | 20/20 tests | βœ… **100%** | ### 🎯 **Test Execution Results** | Test Suite | Tests | Passed | Failed | Success Rate | | ------------------------ | -------- | -------- | ------ | ------------ | | **Unit Tests** | 535+ | 535+ | 0 | **100%** | | **Integration (Auto)** | 15 | 15 | 0 | **100%** | | **Integration (Manual)** | 40 | 40 | 0 | **100%** | | **Protocol Tests** | 20 | 20 | 0 | **100%** | | **TOTAL** | **610+** | **610+** | **0** | **100%** | ### βœ… **All Historical Issues Resolved** | Previous Issue | Status | Resolution | | --------------------------------------- | -------- | ------------------------------------------------ | | Performance tool serialization errors | βœ… Fixed | Response format corrected for MCP protocol | | Query optimization serialization errors | βœ… Fixed | Response format corrected for MCP protocol | | `explain_query` batch limitations | βœ… Fixed | Separate batch execution implemented | | MCP response format compatibility | βœ… Fixed | All tools now return proper MCP responses | | SSL certificate handling | βœ… Fixed | Self-signed certificate trust implemented | | Configuration loading | βœ… Fixed | Environment variable override system implemented | | Test isolation | βœ… Fixed | Manual tests properly excluded from CI/CD | ## Troubleshooting ### Common Issues and Solutions #### Previous Serialization Issues (RESOLVED) **Previous Error**: `"data did not match any variant of untagged enum Response"` **Resolution**: βœ… **FIXED** - All performance and optimization tools now return properly formatted MCP responses. **What was changed**: - Fixed nested `content` structure in performance monitoring methods - Corrected response format in query optimization tools - All tools now conform to MCP protocol requirements #### Connection Issues **Error**: Connection timeout or authentication failures **Solution**: - Verify MCP server configuration - Check database connectivity - Validate authentication credentials - Review SSL/encryption settings #### Security Policy Violations **Error**: `"Query blocked by safety policy"` **Expected Behavior**: This is correct in read-only mode **Solution**: - For testing modifications, set `SQL_SERVER_READ_ONLY=false` - For production, keep security restrictions active ## Validation Criteria ### Pass Criteria - βœ… All database operations (16 tools) work correctly - βœ… Security system properly enforces read-only restrictions - βœ… Data retrieval and export functions correctly - βœ… Query execution and analysis works reliably - βœ… Performance monitoring and optimization tools accessible ### Acceptance Criteria - **100% Core Functionality**: βœ… All database operations work - **100% Security**: βœ… Safety system properly enforced - **100% Data Integrity**: βœ… All data operations return accurate results - **100% Error Handling**: βœ… Clear error messages for policy violations - **100% MCP Compatibility**: βœ… All tools return proper MCP responses ### Production Readiness Assessment #### βœ… FULLY PRODUCTION READY - COMPREHENSIVELY VALIDATED - **βœ… All 16 MCP Tools**: 100% functional across all security phases - **βœ… Three-Tier Security**: 100% validated across 40 integration tests - **βœ… MCP Protocol**: 100% compliant through 20 protocol tests - **βœ… Enterprise Ready**: SSL/TLS, configuration management, error handling - **βœ… Performance Monitoring**: Comprehensive tracking and optimization - **βœ… Code Quality**: 535+ unit tests with extensive coverage **TOTAL VALIDATION**: 610+ tests with 100% success rate ## Testing Architecture Improvements βœ… ### Completed in v1.7.0+ 1. βœ… **Comprehensive Testing Suite**: 610+ tests across all system layers 2. βœ… **Manual Integration Testing**: 40 tests validating all 3 security phases 3. βœ… **Protocol Testing**: 20 tests validating MCP client-server communication 4. βœ… **CI/CD Integration**: Automated tests run on every commit 5. βœ… **Production Validation**: 100% success rate across all test phases 6. βœ… **Test Organization**: Clear separation of automated vs manual testing 7. βœ… **Documentation**: Comprehensive guides for all testing approaches ### Testing Infrastructure 1. βœ… **Unit Tests**: Mock-based testing for rapid development feedback 2. βœ… **Integration Tests**: Live database validation for production readiness 3. βœ… **Protocol Tests**: End-to-end MCP communication validation 4. βœ… **Security Testing**: All three security phases comprehensively validated 5. βœ… **Performance Testing**: Query execution and optimization validation ## Conclusion The SQL Server MCP server has been **comprehensively validated** through extensive testing across all system layers: ### 🎯 **Validation Summary** - **βœ… 610+ Total Tests**: Complete system validation - **βœ… 100% Success Rate**: All tests passing across all phases - **βœ… Production Validated**: Live database testing with real-world scenarios - **βœ… Security Proven**: Three-tier safety system comprehensively tested - **βœ… Protocol Compliant**: Full MCP client-server communication validated - **βœ… Enterprise Ready**: SSL/TLS, performance monitoring, error handling ### πŸš€ **Deployment Confidence** With **100% test success rates** across: - **535+ Unit Tests** - Code logic validation - **15 Integration Tests** - Component integration - **40 Manual Tests** - Security phase validation - **20 Protocol Tests** - MCP communication validation **Overall Assessment**: βœ… **COMPREHENSIVELY VALIDATED - ENTERPRISE PRODUCTION READY** This MCP server demonstrates enterprise-grade software development practices with rigorous testing, robust security, and production-ready reliability. --- _This document should be updated as issues are resolved and new features are added._ ``` ````

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/egarcia74/warp-sql-server-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server