mgbam commited on
Commit
c39a83a
·
verified ·
1 Parent(s): 2b2ae99

Create mcp/mygene.py

Browse files
Files changed (1) hide show
  1. mcp/mcp/mygene.py +13 -0
mcp/mcp/mygene.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import httpx, asyncio
2
+
3
+ _BASE = "https://mygene.info/v3"
4
+
5
+ async def fetch_gene(symbol: str) -> dict:
6
+ async with httpx.AsyncClient(timeout=10) as cli:
7
+ r = await cli.get(f"{_BASE}/query", params={
8
+ "q": symbol, "fields": "symbol,name,summary,go,entrezgene,clinvar",
9
+ "size": 1
10
+ })
11
+ r.raise_for_status()
12
+ hits = r.json().get("hits", [])
13
+ return hits[0] if hits else {}