Skip to main content
Glama
RobertBergman

Cisco Catalyst Center (DNAC) MCP Server

verify_setup.py6.14 kB
#!/usr/bin/env python3 """ Setup verification script for DNAC MCP Server This script verifies that the development environment is correctly set up. """ import sys import subprocess from pathlib import Path def print_header(text: str): """Print formatted header""" print("\n" + "="*80) print(f" {text}") print("="*80) def check_python_version(): """Check Python version is 3.10+""" print_header("Checking Python Version") version = sys.version_info print(f"Python version: {version.major}.{version.minor}.{version.micro}") if version.major >= 3 and version.minor >= 10: print("✓ Python version is 3.10 or higher") return True else: print("✗ Python version must be 3.10 or higher") return False def check_dependencies(): """Check required dependencies are installed""" print_header("Checking Dependencies") required_packages = [ "dnacentersdk", "mcp", "pytest", "black", "ruff" ] all_installed = True for package in required_packages: try: __import__(package) print(f"✓ {package} installed") except ImportError: print(f"✗ {package} NOT installed") all_installed = False return all_installed def check_project_structure(): """Verify project structure is correct""" print_header("Checking Project Structure") required_paths = [ "src/dnac_mcp/__init__.py", "src/dnac_mcp/server.py", "src/dnac_mcp/wireless_client_agent.py", "src/dnac_mcp/config.py", "tests/test_server.py", "tests/test_wireless_client_agent.py", "tests/test_config.py", "pyproject.toml", "requirements.txt", "README.md" ] all_exist = True for path_str in required_paths: path = Path(path_str) if path.exists(): print(f"✓ {path_str}") else: print(f"✗ {path_str} NOT FOUND") all_exist = False return all_exist def run_tests(): """Run test suite""" print_header("Running Tests") try: result = subprocess.run( ["pytest", "-v", "--tb=short"], capture_output=True, text=True, timeout=60 ) print(result.stdout) if result.returncode == 0: print("\n✓ All tests passed") return True else: print(f"\n✗ Tests failed with return code {result.returncode}") print(result.stderr) return False except subprocess.TimeoutExpired: print("✗ Tests timed out") return False except FileNotFoundError: print("✗ pytest not found. Install with: pip install pytest") return False def check_code_formatting(): """Check code formatting with black""" print_header("Checking Code Formatting") try: result = subprocess.run( ["black", "--check", "src", "tests"], capture_output=True, text=True ) if result.returncode == 0: print("✓ Code is properly formatted") return True else: print("✗ Code needs formatting. Run: black src tests") return False except FileNotFoundError: print("✗ black not found. Install with: pip install black") return False def check_linting(): """Check code with ruff""" print_header("Checking Code Linting") try: result = subprocess.run( ["ruff", "check", "src", "tests"], capture_output=True, text=True ) if result.returncode == 0: print("✓ No linting errors") return True else: print("✗ Linting errors found:") print(result.stdout) return False except FileNotFoundError: print("✗ ruff not found. Install with: pip install ruff") return False def check_environment_variables(): """Check if DNAC environment variables are set""" print_header("Checking Environment Variables (Optional)") import os env_vars = { "DNAC_BASE_URL": os.getenv("DNAC_BASE_URL"), "DNAC_USERNAME": os.getenv("DNAC_USERNAME"), "DNAC_PASSWORD": os.getenv("DNAC_PASSWORD") } all_set = True for var, value in env_vars.items(): if value: print(f"✓ {var} is set") else: print(f"ℹ {var} not set (optional for development)") all_set = False if not all_set: print("\nNote: Environment variables are optional for development.") print("Set them to test with actual DNAC instance.") return True # Don't fail on missing env vars def main(): """Run all verification checks""" print("\n" + "="*80) print(" DNAC MCP Server - Setup Verification") print("="*80) checks = [ ("Python Version", check_python_version), ("Dependencies", check_dependencies), ("Project Structure", check_project_structure), ("Tests", run_tests), ("Code Formatting", check_code_formatting), ("Linting", check_linting), ("Environment Variables", check_environment_variables) ] results = {} for name, check_func in checks: try: results[name] = check_func() except Exception as e: print(f"\n✗ Error checking {name}: {e}") results[name] = False # Summary print_header("Summary") passed = sum(1 for v in results.values() if v) total = len(results) for name, result in results.items(): status = "✓ PASS" if result else "✗ FAIL" print(f"{status}: {name}") print(f"\nTotal: {passed}/{total} checks passed") if passed == total: print("\n🎉 Setup verification successful! You're ready to develop.") return 0 else: print("\n⚠️ Some checks failed. Please fix the issues above.") return 1 if __name__ == "__main__": sys.exit(main())

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/RobertBergman/dnac-mcp'

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