Create mcp/mygene.py
Browse files- 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 {}
|