MCPcopy Create free account
hub / github.com/1jehuang/jcode / send_debug_cmd

Function send_debug_cmd

scripts/test_oauth_usage.py:110–129  ·  view source on GitHub ↗

Send a debug command and get response.

(sock, cmd: str, session_id: str = None, timeout: float = 60)

Source from the content-addressed store, hash-verified

108
109
110def send_debug_cmd(sock, cmd: str, session_id: str = None, timeout: float = 60) -> tuple:
111 """Send a debug command and get response."""
112 req = {"type": "debug_command", "id": 1, "command": cmd}
113 if session_id:
114 req["session_id"] = session_id
115
116 sock.send((json.dumps(req) + '\n').encode())
117 sock.settimeout(timeout)
118
119 data = b""
120 while True:
121 chunk = sock.recv(65536)
122 if not chunk:
123 break
124 data += chunk
125 if b'\n' in data:
126 break
127
128 resp = json.loads(data.decode().strip())
129 return resp.get('ok', False), resp.get('output', ''), resp.get('error', '')
130
131
132def run_jcode_oauth(prompt: str) -> dict:

Callers 1

run_jcode_oauthFunction · 0.85

Calls 5

encodeMethod · 0.80
recvMethod · 0.80
decodeMethod · 0.80
sendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected