import json, time, urllib.request
MCP="https://mcp.nonceprotocol.xyz/mcp"
def call():
    body=json.dumps({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"protocol_info","arguments":{}}}).encode()
    req=urllib.request.Request(MCP,data=body,headers={"Content-Type":"application/json","Accept":"application/json, text/event-stream","User-Agent":"curl/8.7.1"})
    with urllib.request.urlopen(req,timeout=40) as r:
        raw=r.read().decode()
    p=json.loads(raw)
    return json.loads(p["result"]["content"][0]["text"])
for attempt in range(6):
    time.sleep(45)
    try:
        d=call()
        print(time.strftime("%H:%M:%S"),"OK admission=",d.get("admission"),"remaining=",d.get("remainingSupply"),"benchmark=",(d.get("benchmark") or {}).get("version"), flush=True)
        break
    except Exception as e:
        print(time.strftime("%H:%M:%S"),"ERR",type(e).__name__,e, flush=True)
