docs(rebar): 위치 안내 및 Rhino 직접 호출 도구 추가

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ahnyongjooandClaude Sonnet 5.5 committed 2026-10-28 11:56:15 +09:00
1 parent 18bd4a5771
commit 62f003d35a
2 files changed
+55

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
r"""Rhino 소켓 서버(포트 9876)에 직접 명령을 보낸다. MCP 도구가 세션에 없을 때 쓴다.
사용: python rhino_call.py get_scene_info
python rhino_call.py execute_code "<IronPython 코드>"
python rhino_call.py execute_code @파일경로.py
"""
import json
import socket
import sys
def call(cmd_type, params=None, host="127.0.0.1", port=9876, timeout=300):
with socket.create_connection((host, port), timeout=timeout) as s:
s.sendall(json.dumps({"type": cmd_type, "params": params or {}}).encode("utf-8"))
buf = b""
while True:
chunk = s.recv(1 << 20)
if not chunk:
break
buf += chunk
try:
return json.loads(buf.decode("utf-8"))
except ValueError:
continue
return json.loads(buf.decode("utf-8"))
if __name__ == "__main__":
sys.stdout.reconfigure(encoding="utf-8")
t = sys.argv[1]
p = {}
if t == "execute_code":
code = sys.argv[2]
if code.startswith("@"):
code = open(code[1:], encoding="utf-8").read()
p = {"code": code}
print(json.dumps(call(t, p), ensure_ascii=False, indent=1)[:6000])