healthcare-api-mcp / core /base_provider.py
visproj's picture
initial commit
0d10048 verified
raw
history blame
1.46 kB
"""Base provider class for healthcare APIs."""
from abc import ABC, abstractmethod
from typing import List, Callable
import httpx
import logging
logger = logging.getLogger(__name__)
class BaseProvider(ABC):
"""Abstract base class for healthcare API providers."""
def __init__(self, name: str, client: httpx.AsyncClient):
"""
Initialize provider.
Args:
name: Provider name (used for tool prefixing)
client: Async HTTP client
"""
self.name = name
self.client = client
self._tools = []
@abstractmethod
async def initialize(self) -> None:
"""
Initialize provider (e.g., test API connection).
Override in subclasses if needed.
"""
pass
@abstractmethod
def get_tools(self) -> List[Callable]:
"""
Return list of MCP tool functions provided by this provider.
Returns:
List of tool functions
"""
pass
async def cleanup(self) -> None:
"""
Cleanup provider resources.
Override in subclasses if needed.
"""
pass
def register_tool(self, func: Callable) -> None:
"""Register a tool function."""
self._tools.append(func)
@property
def tools(self) -> List[Callable]:
"""Get all registered tools."""
return self._tools