mcp.servers.models ================== .. py:module:: mcp.servers.models .. autoapi-nested-parse:: MCP Server-specific models extending base server management framework. This module provides MCP-specific server configuration and runtime information models that extend the base server management framework from haive-dataflow. Key Components: - MCPTransport: Enum for MCP transport types (stdio, http, etc.) - MCPServerConfig: MCP-specific server configuration - MCPServerInfo: MCP runtime information with transport details Classes ------- .. autoapisummary:: mcp.servers.models.MCPServerConfig mcp.servers.models.MCPServerInfo mcp.servers.models.MCPTransport Module Contents --------------- .. py:class:: MCPServerConfig Bases: :py:obj:`haive.dataflow.server_management.models.BaseServerConfig` MCP-specific server configuration. Extends BaseServerConfig with MCP-specific fields like transport type, required environment variables, and protocol version. .. attribute:: transport MCP transport mechanism (stdio, http, etc.) .. attribute:: requires_env List of required environment variable names .. attribute:: protocol_version MCP protocol version (default: "1.0") .. attribute:: capabilities List of server capabilities/features .. attribute:: endpoints Optional endpoints for HTTP/WebSocket transports .. rubric:: Example >>> config = MCPServerConfig( ... name="github", ... command=["npx", "-y", "@modelcontextprotocol/server-github"], ... description="GitHub repository access", ... transport=MCPTransport.STDIO, ... requires_env=["GITHUB_TOKEN"] ... ) .. py:method:: validate_env_vars(v: List[str]) -> List[str] :classmethod: Validate environment variable names. .. py:method:: validate_transport_config() -> MCPServerConfig Validate transport-specific configuration. .. py:attribute:: capabilities :type: List[str] :value: None .. py:attribute:: endpoints :type: Optional[Dict[str, str]] :value: None .. py:attribute:: protocol_version :type: str :value: None .. py:attribute:: requires_env :type: List[str] :value: None .. py:attribute:: transport :type: MCPTransport :value: None .. py:class:: MCPServerInfo Bases: :py:obj:`haive.dataflow.server_management.models.BaseServerInfo` MCP-specific server runtime information. Extends BaseServerInfo with MCP-specific runtime details like transport info, connection status, and protocol negotiation results. .. attribute:: transport Active transport type .. attribute:: transport_info Transport-specific connection details .. attribute:: protocol_version Negotiated protocol version .. attribute:: capabilities_active Currently active capabilities .. attribute:: last_message_time Timestamp of last message exchange .. attribute:: message_count Total messages exchanged .. rubric:: Example >>> info = MCPServerInfo( ... pid=12345, ... status=ServerStatus.RUNNING, ... transport=MCPTransport.STDIO, ... transport_info={"pipes": ["stdin", "stdout", "stderr"]} ... ) .. py:method:: get_transport_status() -> str Get human-readable transport status. .. py:method:: record_message() -> None Record a message exchange. .. py:attribute:: capabilities_active :type: List[str] :value: None .. py:attribute:: last_message_time :type: Optional[datetime.datetime] :value: None .. py:attribute:: message_count :type: int :value: None .. py:attribute:: protocol_version :type: Optional[str] :value: None .. py:attribute:: transport :type: MCPTransport :value: None .. py:attribute:: transport_info :type: Dict[str, Any] :value: None .. py:class:: MCPTransport Bases: :py:obj:`str`, :py:obj:`enum.Enum` MCP transport mechanism types. Defines the communication transport used by MCP servers. .. py:attribute:: HTTP :value: 'http' .. py:attribute:: IPC :value: 'ipc' .. py:attribute:: STDIO :value: 'stdio' .. py:attribute:: UNKNOWN :value: 'unknown' .. py:attribute:: WEBSOCKET :value: 'websocket'