MCP_Res / mcp /mygene.py
mgbam's picture
Update mcp/mygene.py
3ef2946 verified
Raw History Blame
496 Bytes
import os, httpx, asyncio
from functools import lru_cache
_KEY = os.getenv("MYGENE_KEY"); _URL="https://mygene.info/v3/query"
@lru_cache(maxsize=512)
async def fetch_gene_info(sym: str):
p={"q":sym,"fields":"symbol,name,summary,alias,entrezgene,location","size":1}
if _KEY: p["api_key"]=_KEY
async with httpx.AsyncClient(timeout=8) as c:
r=await c.get(_URL,params=p); r.raise_for_status()
return r.json().get("hits",[{}])[0]
``` :contentReference[oaicite:7]{index=7}