#!/usr/bin/env python3 """ Test script for the modularized Enhanced MCP Tools This script tests that all modules can be imported and basic functionality works. """ import os import sys from pathlib import Path # Add the project root to the Python path project_root = Path(__file__).parent.parent # Go up one more level to get to project root sys.path.insert(0, str(project_root)) def test_imports(): """Test that all modules can be imported successfully""" print("๐Ÿงช Testing module imports...") try: from enhanced_mcp.base import MCPBase, MCPMixin print("โœ… Base module imported successfully") from enhanced_mcp.diff_patch import DiffPatchOperations print("โœ… Diff/Patch module imported successfully") from enhanced_mcp.intelligent_completion import IntelligentCompletion print("โœ… Intelligent Completion module imported successfully") from enhanced_mcp.asciinema_integration import AsciinemaIntegration print("โœ… Asciinema Integration module imported successfully") from enhanced_mcp.sneller_analytics import SnellerAnalytics print("โœ… Sneller Analytics module imported successfully") from enhanced_mcp.git_integration import GitIntegration print("โœ… Git Integration module imported successfully") from enhanced_mcp.file_operations import EnhancedFileOperations, MCPEventHandler print("โœ… File Operations module imported successfully") from enhanced_mcp.archive_compression import ArchiveCompression print("โœ… Archive Compression module imported successfully") from enhanced_mcp.workflow_tools import ( AdvancedSearchAnalysis, DevelopmentWorkflow, EnhancedExistingTools, EnvironmentProcessManagement, NetworkAPITools, ProcessTracingTools, UtilityTools, ) print("โœ… Workflow Tools module imported successfully") from enhanced_mcp.mcp_server import MCPToolServer, create_server, run_server print("โœ… MCP Server module imported successfully") from enhanced_mcp import MCPToolServer as MainServer print("โœ… Main package import successful") print("\n๐ŸŽ‰ All modules imported successfully!") assert True # Test passed except ImportError as e: print(f"โŒ Import failed: {e}") assert False, f"Import failed: {e}" except Exception as e: print(f"โŒ Unexpected error: {e}") assert False, f"Unexpected error: {e}" def test_instantiation(): """Test that we can instantiate the main classes""" print("\n๐Ÿงช Testing class instantiation...") try: from enhanced_mcp.mcp_server import MCPToolServer # Create main server instance server = MCPToolServer("Test Server") print("โœ… MCPToolServer instantiated successfully") # Test that all tool modules are accessible tools = server.tools print(f"โœ… Found {len(tools)} tool modules:") for name, tool in tools.items(): print(f" - {name}: {tool.__class__.__name__}") # Test the intelligent completion system completion = server.completion if hasattr(completion, "tool_categories"): categories = list(completion.tool_categories.keys()) print(f"โœ… Intelligent completion has {len(categories)} tool categories: {categories}") print("\n๐ŸŽ‰ All classes instantiated successfully!") assert True # Test passed except Exception as e: print(f"โŒ Instantiation failed: {e}") assert False, f"Instantiation failed: {e}" def test_structure(): """Test the overall structure and architecture""" print("\n๐Ÿงช Testing architecture structure...") try: # Check that we have the expected file structure enhanced_mcp_dir = project_root / "enhanced_mcp" expected_files = [ "__init__.py", "base.py", "diff_patch.py", "intelligent_completion.py", "asciinema_integration.py", "sneller_analytics.py", "git_integration.py", "file_operations.py", "archive_compression.py", "workflow_tools.py", "mcp_server.py", ] missing_files = [] for filename in expected_files: filepath = enhanced_mcp_dir / filename if not filepath.exists(): missing_files.append(filename) if missing_files: print(f"โŒ Missing files: {missing_files}") assert False, f"Missing files: {missing_files}" print(f"โœ… All {len(expected_files)} expected files present") # Check file sizes to ensure content was extracted properly large_files = [ "asciinema_integration.py", "sneller_analytics.py", "git_integration.py", "archive_compression.py", ] for filename in large_files: filepath = enhanced_mcp_dir / filename size = filepath.stat().st_size if size < 1000: # Less than 1KB suggests empty/minimal file print(f"โš ๏ธ Warning: {filename} seems small ({size} bytes)") else: print(f"โœ… {filename}: {size:,} bytes") print("\n๐ŸŽ‰ Architecture structure looks good!") assert True # Test passed except Exception as e: print(f"โŒ Structure test failed: {e}") assert False, f"Structure test failed: {e}" def main(): """Run all tests""" print("๐Ÿš€ Testing Enhanced MCP Tools Modular Structure") print("=" * 60) success = True # Run tests success &= test_imports() success &= test_instantiation() success &= test_structure() print("\n" + "=" * 60) if success: print("๐ŸŽ‰ All tests passed! The modular structure is working correctly.") print("\n๐Ÿ“ฆ Module Summary:") print(" - Base functionality: base.py") print(" - Diff/Patch ops: diff_patch.py") print(" - AI recommendations: intelligent_completion.py") print(" - Terminal recording: asciinema_integration.py") print(" - High-perf analytics: sneller_analytics.py") print(" - Git operations: git_integration.py") print(" - File operations: file_operations.py") print(" - Archive/compress: archive_compression.py") print(" - Workflow tools: workflow_tools.py") print(" - Server composition: mcp_server.py") print("\n๐ŸŽฏ Ready for production use!") else: print("โŒ Some tests failed. Please check the errors above.") sys.exit(1) if __name__ == "__main__": main()