Download mcp/ctgov.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/41bca2200dd3bc86d1312ad269a00e8b60c0cfd9/mcp/ctgov.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@41bca2200dd3bc86d1312ad269a00e8b60c0cfd9/mcp/ctgov.py
-
curl -L -o ctgov.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/41bca2200dd3bc86d1312ad269a00e8b60c0cfd9/mcp/ctgov.py
761 Bytes
| """ClinicalTrials.gov v2 async helper. | |
| Docs: https://clinicaltrials.gov/api/gui/ref/api_urls#v2 | |
| Provides `search_trials_v2` which returns a list of study dicts. | |
| """ | |
| import httpx, asyncio | |
| from typing import List, Dict | |
| _BASE = "https://clinicaltrials.gov/api/v2/studies" | |
| async def search_trials_v2(query: str, *, max_n: int = 20) -> List[Dict]: | |
| """Search CT.gov v2 endpoint and return list of studies.""" | |
| params = { | |
| "query": query, | |
| "pageSize": max_n, | |
| "fields": "nctId,briefTitle,phase,status,startDate,conditions,interventions", | |
| } | |
| async with httpx.AsyncClient(timeout=15) as client: | |
| resp = await client.get(_BASE, params=params) | |
| resp.raise_for_status() | |
| return resp.json().get("studies", []) |