Datasets:
Download examples/query_apify_mcp.py from Serisly/ecommerce-brand-app-stack-sample: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/Serisly/ecommerce-brand-app-stack-sample/resolve/main/examples/query_apify_mcp.py
- Command line
-
hf download hf://datasets/Serisly/ecommerce-brand-app-stack-sample/examples/query_apify_mcp.py
-
curl -L -o query_apify_mcp.py https://huggingface.co/datasets/Serisly/ecommerce-brand-app-stack-sample/resolve/main/examples/query_apify_mcp.py
1.03 kB
| """Minimal Python client for the Apify Standby HTTP & Streamable HTTP MCP endpoint.""" | |
| import json | |
| import os | |
| import urllib.request | |
| STANDBY_URL = "https://mrTHhreuuBNgcAaIQ.apify.actor" | |
| TOKEN = os.environ["APIFY_TOKEN"] | |
| def call_mcp_tool(arguments: dict) -> dict: | |
| payload = { | |
| "jsonrpc": "2.0", | |
| "id": 1, | |
| "method": "tools/call", | |
| "params": { | |
| "name": "query_ecommerce_brands", | |
| "arguments": arguments, | |
| }, | |
| } | |
| req = urllib.request.Request( | |
| f"{STANDBY_URL}/mcp", | |
| data=json.dumps(payload).encode("utf-8"), | |
| headers={ | |
| "Authorization": f"Bearer {TOKEN}", | |
| "Content-Type": "application/json", | |
| }, | |
| method="POST", | |
| ) | |
| with urllib.request.urlopen(req, timeout=30) as resp: | |
| return json.loads(resp.read().decode("utf-8")) | |
| if __name__ == "__main__": | |
| res = call_mcp_tool({'platforms': ['shopify'], 'verifiedCorporateOnly': True, 'maxItems': 25}) | |
| print(json.dumps(res, indent=2)[:2000]) | |