"""Send a Python file to the running Blender (Blender Lab MCP add-on on localhost:9876) and print the reply. Usage: python send.py script.py """ import json import socket import sys code = open(sys.argv[1], encoding="utf-8").read() payload = (json.dumps({"type": "execute", "code": code, "strict_json": False}) + "\0").encode("utf-8") with socket.create_connection(("localhost", 9876), timeout=600) as s: s.sendall(payload) buf = bytearray() while b"\0" not in buf: chunk = s.recv(65536) if not chunk: break buf.extend(chunk) end = buf.index(b"\0") if b"\0" in buf else len(buf) print(json.dumps(json.loads(bytes(buf[:end])), ensure_ascii=False, indent=1))