base.py•1.77 kB
"""
Base registry client interface.
"""
from abc import ABC, abstractmethod
from typing import Any, Dict
class RegistryClient(ABC):
"""
Abstract base class for registry clients.
This interface allows different registry backends to be supported
by implementing this interface.
"""
@abstractmethod
async def register(self, server_info: Dict[str, Any]) -> Dict[str, Any]:
"""
Register the MCP server with the registry.
Args:
server_info: Server information to register
Returns:
Registration response from registry
"""
pass
@abstractmethod
async def deregister(self, server_id: str) -> bool:
"""
Deregister the MCP server from the registry.
Args:
server_id: Unique server identifier
Returns:
True if deregistration was successful
"""
pass
@abstractmethod
async def heartbeat(self, server_id: str) -> bool:
"""
Send heartbeat to maintain registration.
Args:
server_id: Unique server identifier
Returns:
True if heartbeat was successful
"""
pass
@abstractmethod
async def update_metadata(self, server_id: str, metadata: Dict[str, Any]) -> bool:
"""
Update server metadata in the registry.
Args:
server_id: Unique server identifier
metadata: Updated metadata
Returns:
True if update was successful
"""
pass
@abstractmethod
async def health_check(self) -> bool:
"""
Check if registry is accessible.
Returns:
True if registry is healthy
"""
pass