Download mcp/wikidata.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 592 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/8e8bfa64459c58f44ea635139b38e6b394629682/mcp/wikidata.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@8e8bfa64459c58f44ea635139b38e6b394629682/mcp/wikidata.py
-
curl -L -o wikidata.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/8e8bfa64459c58f44ea635139b38e6b394629682/mcp/wikidata.py
592 Bytes
| # 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 | |