Spaces:
Starting on CPU Upgrade

mgbam commited on
Commit
c09fa6f
·
verified ·
1 Parent(s): 1e9f684

Create ctgov.py

Browse files
Files changed (1) hide show
  1. mcp/ctgov.py +13 -0
mcp/ctgov.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import httpx, asyncio, datetime
2
+
3
+ _BASE = "https://clinicaltrials.gov/api/v2/studies"
4
+
5
+ async def search_trials(query: str, max_n: int = 20) -> list[dict]:
6
+ async with httpx.AsyncClient(timeout=15) as cli:
7
+ r = await cli.get(_BASE, params={
8
+ "query": query,
9
+ "pageSize": max_n,
10
+ "fields": "nctId,briefTitle,phase,status,startDate"
11
+ })
12
+ r.raise_for_status()
13
+ return r.json().get("studies", [])