Files

26 lines
706 B
Python

import urllib.request
import json
def call_mcp(method, params={}):
url = "http://192.168.68.118/api/mcp"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": method,
"params": params
}
req = urllib.request.Request(
url,
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST"
)
try:
with urllib.request.urlopen(req, timeout=5.0) as resp:
return json.loads(resp.read().decode("utf-8"))
except Exception as e:
return {"error": str(e)}
res = call_mcp("tools/call", {"name": "get_stream_stats", "arguments": {}})
print(json.dumps(res, indent=2))