Skip to main content
Glama

Cyber Sentinel MCP Server

by jx888-max
MIT License
2
install.py8.69 kB
#!/usr/bin/env python3 """ Cyber Sentinel MCP Server - Installation Script """ import os import sys import subprocess import platform from pathlib import Path from rich.console import Console from rich.panel import Panel from rich.prompt import Confirm from rich.progress import Progress, SpinnerColumn, TextColumn console = Console() class CyberSentinelInstaller: """Cyber Sentinel MCP Server installer""" def __init__(self): self.python_executable = sys.executable self.platform = platform.system().lower() def check_requirements(self) -> bool: """Check system requirements""" console.print("[bold]检查系统要求...[/bold]") # Check Python version python_version = sys.version_info if python_version < (3, 8): console.print(f"[red]❌ Python {python_version.major}.{python_version.minor} 不受支持[/red]") console.print("需要Python 3.8或更高版本") return False else: console.print(f"[green]✅ Python {python_version.major}.{python_version.minor}.{python_version.micro}[/green]") # Check pip try: subprocess.run([self.python_executable, "-m", "pip", "--version"], capture_output=True, check=True) console.print("[green]✅ pip可用[/green]") except subprocess.CalledProcessError: console.print("[red]❌ pip不可用[/red]") return False # Check internet connectivity try: import urllib.request urllib.request.urlopen('https://pypi.org', timeout=5) console.print("[green]✅ 网络连接正常[/green]") except: console.print("[red]❌ 无网络连接[/red]") return False return True def install_dependencies(self) -> bool: """Install required dependencies""" console.print("\n[bold]安装依赖包...[/bold]") dependencies = [ "mcp", "httpx", "pydantic-settings", "rich", "asyncio-throttle" ] try: with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}")) as progress: task = progress.add_task("安装依赖包...", total=None) for dep in dependencies: result = subprocess.run([ self.python_executable, "-m", "pip", "install", dep ], capture_output=True, text=True) if result.returncode != 0: console.print(f"[red]❌ 安装 {dep} 失败[/red]") console.print(f"错误: {result.stderr}") return False progress.update(task, completed=True) console.print("[green]✅ 依赖包安装完成[/green]") return True except Exception as e: console.print(f"[red]❌ 依赖包安装失败: {e}[/red]") return False def install_cyber_sentinel(self) -> bool: """Install Cyber Sentinel package""" console.print("\n[bold]安装Cyber Sentinel...[/bold]") try: with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}")) as progress: task = progress.add_task("安装Cyber Sentinel...", total=None) # Install in development mode if we're in the source directory if (Path.cwd() / "pyproject.toml").exists(): result = subprocess.run([ self.python_executable, "-m", "pip", "install", "-e", "." ], capture_output=True, text=True) else: # Install from PyPI (when available) result = subprocess.run([ self.python_executable, "-m", "pip", "install", "cyber-sentinel-mcp" ], capture_output=True, text=True) if result.returncode != 0: console.print("[red]❌ Cyber Sentinel安装失败[/red]") console.print(f"错误: {result.stderr}") return False progress.update(task, completed=True) console.print("[green]✅ Cyber Sentinel安装完成[/green]") return True except Exception as e: console.print(f"[red]❌ 安装失败: {e}[/red]") return False def show_env_setup_instructions(self): """显示环境变量设置说明""" console.print("\n[bold cyan]环境变量配置说明[/bold cyan]") console.print("Cyber Sentinel现在直接从环境变量读取配置,无需.env文件。") console.print("请在运行setup wizard后设置相应的环境变量。") console.print("\n[yellow]示例环境变量:[/yellow]") console.print("VIRUSTOTAL_API_KEY=your_api_key_here") console.print("ABUSEIPDB_API_KEY=your_api_key_here") console.print("LOG_LEVEL=INFO") def show_next_steps(self): """Show next steps to user""" console.print(Panel.fit( "[bold green]🎉 安装完成![/bold green]\n\n" "下一步:\n" "1. 配置API密钥: [cyan]python -m cyber_sentinel.setup_wizard[/cyan]\n" "2. 测试配置: [cyan]python -m cyber_sentinel.diagnostics[/cyan]\n" "3. 启动服务器: [cyan]python -m cyber_sentinel.server[/cyan]\n\n" "详细设置帮助,请访问:\n" "[blue]https://github.com/yourusername/cyber-sentinel-mcp[/blue]", title="成功" )) def run_installation(self): """Run the complete installation process""" console.print(Panel.fit( "[bold blue]🛡️ Cyber Sentinel MCP Server 安装程序[/bold blue]\n\n" "此安装程序将在您的系统上设置Cyber Sentinel。\n" "过程包括:\n" "• 安装Python依赖包\n" "• 设置Cyber Sentinel包\n" "• 显示环境变量配置说明", title="欢迎" )) if not Confirm.ask("\n继续安装?"): console.print("安装已取消。") return False try: # Check requirements if not self.check_requirements(): console.print("[red]❌ 系统要求检查失败[/red]") return False # Install dependencies if not self.install_dependencies(): console.print("[red]❌ 依赖包安装失败[/red]") return False # Install Cyber Sentinel if not self.install_cyber_sentinel(): console.print("[red]❌ Cyber Sentinel安装失败[/red]") return False # Show environment setup instructions console.print("\n[bold]显示环境变量配置说明...[/bold]") self.show_env_setup_instructions() # Show next steps self.show_next_steps() # Ask if user wants to run setup wizard if Confirm.ask("\n您想现在运行设置向导吗?"): try: subprocess.run([ self.python_executable, "-m", "cyber_sentinel.setup_wizard" ]) except Exception as e: console.print(f"[yellow]⚠️ 无法启动设置向导: {e}[/yellow]") console.print("您可以稍后手动运行: [cyan]python -m cyber_sentinel.setup_wizard[/cyan]") return True except KeyboardInterrupt: console.print("\n[yellow]用户取消了安装。[/yellow]") return False except Exception as e: console.print(f"[red]安装错误: {e}[/red]") return False def main(): """Main entry point""" installer = CyberSentinelInstaller() success = installer.run_installation() if success: console.print("\n[green]安装成功完成![/green]") sys.exit(0) else: console.print("\n[red]安装失败。[/red]") sys.exit(1) if __name__ == "__main__": main()

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/jx888-max/cyber-sentinel-mcp'

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