#!/usr/bin/env python3 import json, os, sys, urllib.request, urllib.error URL = os.environ.get('GELO_GATEWAY_URL', 'https://api.gelollc.com').rstrip('/') + '/mcp' KEY = os.environ.get('GELO_GATEWAY_KEY', '') for line in sys.stdin: try: message = json.loads(line) req = urllib.request.Request(URL, data=json.dumps(message).encode(), headers={'Authorization':'Bearer '+KEY, 'Content-Type':'application/json', 'Accept':'application/json, text/event-stream'}) with urllib.request.urlopen(req, timeout=70) as response: body = response.read().decode() if body: print(body, flush=True) except Exception as exc: if 'message' in locals() and message.get('id') is not None: print(json.dumps({'jsonrpc':'2.0','id':message['id'],'error':{'code':-32603,'message':'Gateway request failed; check key, connection and usage. Do not automatically replay paid requests.'}}), flush=True)