Download mcp/clinicaltrials.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 736 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/392591064f42dbd2d1f5bde48d8f2eb2c2bbfd0f/mcp/clinicaltrials.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@392591064f42dbd2d1f5bde48d8f2eb2c2bbfd0f/mcp/clinicaltrials.py
-
curl -L -o clinicaltrials.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/392591064f42dbd2d1f5bde48d8f2eb2c2bbfd0f/mcp/clinicaltrials.py
736 Bytes
| # mcp/clinicaltrials.py | |
| """ | |
| ClinicalTrials.gov helper – fetch recent trials for a keyword. | |
| """ | |
| import httpx, datetime | |
| from typing import List | |
| BASE = "https://clinicaltrials.gov/api/query/study_fields" | |
| async def search_trials(term: str, max_studies: int = 10) -> List[dict]: | |
| today = datetime.date.today().isoformat() | |
| params = { | |
| "expr": term, | |
| "fields": "NCTId,BriefTitle,Condition,InterventionName,Phase,OverallStatus,StartDate", | |
| "max_rnk": max_studies, | |
| "fmt": "json", | |
| "min_rnk": 1 | |
| } | |
| async with httpx.AsyncClient(timeout=20) as client: | |
| r = await client.get(BASE, params=params) | |
| r.raise_for_status() | |
| return r.json()["StudyFieldsResponse"]["StudyFields"] | |