# 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 | |