File size: 1,456 Bytes
0d10048
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""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