MCP_Res / mcp /drugcentral.py
mgbam's picture
Create drugcentral.py
e83c230 verified
raw
history blame
553 Bytes
"""DrugCentral async wrapper (https://drugcentral.org/api).
Provides drug metadata, approvals, MoA, off‑label, etc.
"""
import httpx, asyncio
from functools import lru_cache
_BASE = "https://drugcentral.org/api/v1/drug"
@lru_cache(maxsize=256)
async def fetch_drugcentral(drug_name: str) -> dict | None:
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(_BASE, params={"name": drug_name})
if resp.status_code == 404:
return None
resp.raise_for_status()
return resp.json()