Skip to main content
Glama
test_config.py4.84 kB
""" Test script for the Sectional MCP Panel configuration system. """ import asyncio import sys import os import json from pathlib import Path # Add the project root to the Python path project_root = Path(__file__).parent.parent sys.path.append(str(project_root)) from src.config.config_manager import ConfigManager from src.config.models import PanelConfiguration async def test_configuration_system(): """Test the configuration system functionality.""" print("Testing configuration system...") # Initialize the configuration manager config_manager = ConfigManager() print("Configuration manager initialized") # Test configuration validation test_config = { "configSchemaVersion": "1.0.0", "panelName": "Test Panel", "globalDefaults": { "settings": { "environmentVars": { "GLOBAL_ENV": "test" }, "resourceLimits": { "cpuRequest": 0.1, "cpuLimit": 0.5, "memoryRequestMB": 64, "memoryLimitMB": 128 }, "runtimeOptions": { "restartPolicy": "on_failure", "maxRestarts": 3, "terminationGracePeriodSeconds": 30 } } }, "sections": [ { "sectionName": "Test Section", "description": "A test section", "settings": { "environmentVars": { "SECTION_ENV": "test_section" } }, "servers": [ { "serverName": "Test Server", "description": "A test server", "runtimeDefinition": { "type": "docker_image", "command": "nginx:latest", "args": [], "ports": [ { "containerPort": 80, "protocol": "TCP" } ] }, "settings": { "environmentVars": { "SERVER_ENV": "test_server" } } } ] } ] } # Validate the configuration is_valid = config_manager.validate_config(test_config) print(f"Configuration validation result: {is_valid}") if not is_valid: print("Configuration validation failed") return # Test configuration resolution global_settings = test_config["globalDefaults"]["settings"] section_settings = test_config["sections"][0]["settings"] server_settings = test_config["sections"][0]["servers"][0]["settings"] # Resolve server settings resolved_settings = config_manager.resolve_server_settings( global_settings, section_settings, server_settings ) print("\nResolved settings:") print(f"Environment variables: {resolved_settings['environmentVars']}") print(f"Resource limits: {resolved_settings['resourceLimits']}") print(f"Runtime options: {resolved_settings['runtimeOptions']}") # Verify that server settings override section settings, which override global settings assert resolved_settings["environmentVars"]["GLOBAL_ENV"] == "test" assert resolved_settings["environmentVars"]["SECTION_ENV"] == "test_section" assert resolved_settings["environmentVars"]["SERVER_ENV"] == "test_server" print("\nConfiguration resolution test passed") # Test Pydantic models try: panel_config = PanelConfiguration( configSchemaVersion="1.0.0", panelName="Test Panel", globalDefaults={ "settings": { "environmentVars": {"GLOBAL_ENV": "test"}, "resourceLimits": { "cpuRequest": 0.1, "cpuLimit": 0.5, "memoryRequestMB": 64, "memoryLimitMB": 128 } } } ) print("\nPydantic model validation passed") print(f"Panel name: {panel_config.panelName}") print(f"Config schema version: {panel_config.configSchemaVersion}") except Exception as e: print(f"Pydantic model validation failed: {e}") print("\nConfiguration system test completed successfully") if __name__ == "__main__": asyncio.run(test_configuration_system())

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/rblake2320/sectional-mcp-panel'

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