#!/usr/bin/env python3
"""
MCP-OS (Model Context Protocol Operating System)
완전한 로컬 AI 운영체제 및 MCP 통합 시스템
구조:
- core/: 핵심 시스템 (orchestrator, cli)
- modules/: MCP 모듈들 (terminal, filesystem, debugger 등)
- integrations/: 외부 통합 (shrimp, context7, unigui)
"""
# 핵심 컴포넌트 임포트
try:
from .core.orchestrator.core import MCPOSLocalOrchestrator
from .core.orchestrator.models import (
ModuleStatus, ModuleType, WorkflowType, ResourceType,
LocalModuleInfo, LocalWorkflowTask, LocalResourceMetrics, LocalWorkflowResult
)
ORCHESTRATOR_AVAILABLE = True
except ImportError as e:
print(f"⚠️ Orchestrator 임포트 실패: {e}")
ORCHESTRATOR_AVAILABLE = False
# MCP 모듈들 임포트
try:
# 터미널 모듈
from .modules.terminal.complete_terminal_mcp import CompleteTerminalMCP
from .modules.terminal.models import CommandCategory, ExecutionResult
# 파일시스템 모듈
from .modules.filesystem.complete_filesystem_mcp import CompleteFilesystemMCP
from .modules.filesystem.models import PermissionLevel, FileOperation
# 편집 모듈
from .modules.edit_file_lines.complete_edit_file_lines_mcp import CompleteEditFileLinesMCP
from .modules.edit_file_lines.models import EditStatus, EditMode
# 디버거 모듈
from .modules.debugger.mcp_debugger_main import MCPDebugger
from .modules.debugger.models import DebuggerLanguage, DebuggerState
# 웹 검색 모듈
from .modules.web_search.enhanced_google_search_mcp import EnhancedGoogleSearchMCP
MODULES_AVAILABLE = True
except ImportError as e:
print(f"⚠️ 일부 MCP 모듈 임포트 실패: {e}")
MODULES_AVAILABLE = False
# 통합 모듈들 임포트
try:
# Shrimp 작업 관리자
from .integrations.shrimp.shrimp_main import ShrimpTaskManager
# Context7 문서 시스템
from .integrations.context7.context7_main import Context7MCP
# UniGUI 웹 모듈
from .integrations.unigui.unigui_web_module import WebModuleMCP
INTEGRATIONS_AVAILABLE = True
except ImportError as e:
print(f"⚠️ 일부 통합 모듈 임포트 실패: {e}")
INTEGRATIONS_AVAILABLE = False
# 메인 MCP-OS 클래스
class MCPOS:
"""
MCP-OS 메인 클래스
모든 MCP 모듈과 통합 기능을 관리하는 중앙 허브
"""
def __init__(self):
self.orchestrator = None
self.modules = {}
self.integrations = {}
# 오케스트레이터 초기화
if ORCHESTRATOR_AVAILABLE:
try:
self.orchestrator = MCPOSLocalOrchestrator()
print("✅ MCP-OS Orchestrator 초기화 완료")
except Exception as e:
print(f"❌ Orchestrator 초기화 실패: {e}")
# 모듈들 초기화
if MODULES_AVAILABLE:
self._initialize_modules()
# 통합 모듈들 초기화
if INTEGRATIONS_AVAILABLE:
self._initialize_integrations()
def _initialize_modules(self):
"""MCP 모듈들 초기화"""
try:
self.modules['terminal'] = CompleteTerminalMCP()
self.modules['filesystem'] = CompleteFilesystemMCP()
self.modules['edit_file_lines'] = CompleteEditFileLinesMCP()
self.modules['debugger'] = MCPDebugger()
self.modules['web_search'] = EnhancedGoogleSearchMCP()
print("✅ MCP 모듈들 초기화 완료")
except Exception as e:
print(f"❌ MCP 모듈 초기화 실패: {e}")
def _initialize_integrations(self):
"""통합 모듈들 초기화"""
try:
self.integrations['shrimp'] = ShrimpTaskManager()
self.integrations['context7'] = Context7MCP()
self.integrations['unigui'] = WebModuleMCP()
print("✅ 통합 모듈들 초기화 완료")
except Exception as e:
print(f"❌ 통합 모듈 초기화 실패: {e}")
def get_module(self, module_name: str):
"""모듈 인스턴스 반환"""
if module_name in self.modules:
return self.modules[module_name]
elif module_name in self.integrations:
return self.integrations[module_name]
else:
raise ValueError(f"모듈을 찾을 수 없음: {module_name}")
def list_modules(self):
"""사용 가능한 모듈 목록 반환"""
return {
"modules": list(self.modules.keys()),
"integrations": list(self.integrations.keys()),
"orchestrator_available": self.orchestrator is not None
}
def cleanup(self):
"""리소스 정리"""
if self.orchestrator:
self.orchestrator.cleanup()
for module in self.modules.values():
if hasattr(module, 'cleanup'):
module.cleanup()
for integration in self.integrations.values():
if hasattr(integration, 'cleanup'):
integration.cleanup()
# 편의 함수들
def create_mcp_os():
"""MCP-OS 인스턴스 생성"""
return MCPOS()
def get_orchestrator():
"""오케스트레이터 인스턴스 반환"""
if ORCHESTRATOR_AVAILABLE:
return MCPOSLocalOrchestrator()
else:
raise ImportError("Orchestrator가 사용 불가능합니다")
# 전역 exports
__all__ = [
# 메인 클래스
'MCPOS',
# 편의 함수
'create_mcp_os',
'get_orchestrator',
# 가용성 플래그
'ORCHESTRATOR_AVAILABLE',
'MODULES_AVAILABLE',
'INTEGRATIONS_AVAILABLE',
]
# 조건부 exports
if ORCHESTRATOR_AVAILABLE:
__all__.extend([
'MCPOSLocalOrchestrator',
'ModuleStatus', 'ModuleType', 'WorkflowType', 'ResourceType',
'LocalModuleInfo', 'LocalWorkflowTask', 'LocalResourceMetrics', 'LocalWorkflowResult'
])
if MODULES_AVAILABLE:
__all__.extend([
'CompleteTerminalMCP', 'CompleteFilesystemMCP', 'CompleteEditFileLinesMCP',
'MCPDebugger', 'EnhancedGoogleSearchMCP'
])
if INTEGRATIONS_AVAILABLE:
__all__.extend([
'ShrimpTaskManager', 'Context7MCP', 'WebModuleMCP'
])
# 버전 정보
__version__ = "1.0.0"
__author__ = "MCP-OS Team"
__description__ = "완전한 로컬 AI 운영체제 및 MCP 통합 시스템"