from fastapi import APIRouter
from app.api.dependencies import ServiceContainer
import os
# Import routers
from .sessions import create_sessions_router
from .documents import create_documents_router
from .tts import create_tts_router
from .general import create_general_router
from .stt import create_stt_router
from .user import create_users_router
from .nodes import create_nodes_router
from .skills import create_skills_router
from .agent_update import create_agent_update_router
from .admin import create_admin_router
from .mcp import create_mcp_router

def create_api_router(services: ServiceContainer) -> APIRouter:
    """
    Creates and returns a main APIRouter that includes all sub-routers.
    """
    router = APIRouter()

    # Include routers for different functionalities
    router.include_router(create_general_router(services))
    router.include_router(create_sessions_router(services))
    router.include_router(create_documents_router(services))
    router.include_router(create_tts_router(services))
    router.include_router(create_stt_router(services))
    router.include_router(create_users_router(services))
    router.include_router(create_nodes_router(services))
    router.include_router(create_skills_router(services))
    router.include_router(create_agent_update_router())
    router.include_router(create_admin_router(), prefix="/admin")
    
    from .agents import create_agents_router
    router.include_router(create_agents_router(services), prefix="/agents", tags=["Agents"])

    # MCP SSE Server (Anthropic Model Context Protocol)
    router.include_router(create_mcp_router(services), prefix="/mcp", tags=["MCP"])

    return router