File size: 592 Bytes
1acc892 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# mcp/wikidata.py
"""
Minimal Wikidata entity lookup for biomedical concepts.
"""
import httpx
from typing import Dict, Optional
API = "https://www.wikidata.org/w/api.php"
async def simple_search(term: str) -> Optional[Dict]:
params = {
"action": "wbsearchentities",
"search": term,
"language": "en",
"format": "json",
"limit": 1
}
async with httpx.AsyncClient(timeout=15) as client:
r = await client.get(API, params=params)
r.raise_for_status()
data = r.json()["search"]
return data[0] if data else None
|