Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-mcp/src/lexigram/ai/mcp/transport/base.py: 100%
13 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""Base transport for MCP server."""
3from __future__ import annotations
5from abc import ABC, abstractmethod
6from typing import Any
9class AbstractTransport(ABC):
10 """Abstract base class for MCP transport implementations.
12 A transport handles the I/O layer - reading requests and
13 writing responses. The MCP server is transport-agnostic.
14 """
16 @abstractmethod
17 async def start(self) -> None:
18 """Start the transport."""
20 @abstractmethod
21 async def stop(self) -> None:
22 """Stop the transport."""
24 @abstractmethod
25 async def send(self, message: dict[str, Any]) -> None:
26 """Send a message through the transport.
28 Args:
29 message: JSON-RPC message to send.
30 """
32 @abstractmethod
33 async def receive(self) -> dict[str, Any] | None:
34 """Receive a message from the transport.
36 Returns:
37 Parsed JSON-RPC message, or None if no message available.
38 """
41__all__ = ["AbstractTransport"]