Download mcp/opentargets.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/opentargets.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/opentargets.py
-
curl -L -o opentargets.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/3cb1988088965b28563c0d8c32d2d904b3a93485/mcp/opentargets.py
755 Bytes
| # mcp/opentargets.py | |
| import textwrap | |
| from functools import lru_cache | |
| from mcp.clients import BaseClient | |
| class OTClient(BaseClient): | |
| QUERY = textwrap.dedent(""" | |
| query ($g: String!, $n: Int!){ | |
| associations(geneSymbol: $g, size: $n) { | |
| rows { score datatypeId datasourceId disease { id name } target { id symbol } } | |
| } | |
| } | |
| """) | |
| def __init__(self): | |
| super().__init__("https://api.platform.opentargets.org/api/v4/graphql", api_key_env="OT_KEY") | |
| async def fetch(self, symbol: str, n: int = 30): | |
| payload = {"query": self.QUERY, "variables": {"g": symbol, "n": n}} | |
| return (await self.request("POST", "", json=payload))["data"]["associations"]["rows"] | |
| ot = OTClient() | |