File size: 1,028 Bytes
34a9767
 
 
 
 
 
34495dc
34a9767
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21dac4f
34a9767
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""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])