"""Base transport interface for MCP server."""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mcp.server import Server


class Transport(ABC):
    """Abstract base class for MCP server transports.
    
    A transport handles the communication layer between MCP clients and the server.
    Different transports support different protocols (stdio, HTTP, WebSocket, etc.).
    """
    
    @abstractmethod
    async def start(self, server: Server) -> None:
        """Start the transport and begin accepting connections.
        
        Args:
            server: The MCP server instance to serve
            
        Raises:
            TransportError: If the transport fails to start
        """
        pass
    
    @abstractmethod
    async def stop(self) -> None:
        """Stop the transport and close all connections.
        
        Should gracefully shut down, finishing pending requests if possible.
        
        Raises:
            TransportError: If the transport fails to stop cleanly
        """
        pass
    
    @property
    @abstractmethod
    def transport_type(self) -> str:
        """Get the transport type identifier.
        
        Returns:
            String identifying the transport type (e.g., "stdio", "http", "websocket")
        """
        pass

