Back in business
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
Human-friendly MCP test client.
|
||||
|
||||
Usage: ue-wingman.py <command> [key=value ...]
|
||||
ue-wingman.py (reads JSON with "command" from stdin)
|
||||
|
||||
Values starting with '[' or '{' are parsed as JSON.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -18,33 +19,19 @@ TIMEOUT = 120
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
# No arguments: read a complete JSON object from stdin.
|
||||
# The JSON must already contain a "command" key.
|
||||
decoder = json.JSONDecoder()
|
||||
raw = ""
|
||||
msg = None
|
||||
for line in sys.stdin:
|
||||
raw += line
|
||||
stripped = raw.strip()
|
||||
print("Usage: ue-wingman.py <command> [key=value ...]")
|
||||
sys.exit(1)
|
||||
|
||||
msg = {"command": args[0]}
|
||||
for arg in args[1:]:
|
||||
key, _, value = arg.partition("=")
|
||||
if value and value[0] in ('[', '{'):
|
||||
try:
|
||||
msg, _ = decoder.raw_decode(stripped)
|
||||
break
|
||||
value = json.loads(value)
|
||||
except json.JSONDecodeError as e:
|
||||
if e.pos < len(stripped):
|
||||
print(f"Malformed JSON: {e.msg}")
|
||||
sys.exit(1)
|
||||
continue
|
||||
if msg is None:
|
||||
print("Could not parse a complete JSON object from stdin")
|
||||
sys.exit(1)
|
||||
if "command" not in msg:
|
||||
print("JSON object must contain a \"command\" key")
|
||||
sys.exit(1)
|
||||
else:
|
||||
msg = {"command": args[0]}
|
||||
for arg in args[1:]:
|
||||
key, _, value = arg.partition("=")
|
||||
msg[key] = value
|
||||
print(f"Bad JSON in {key}: {e.msg}")
|
||||
sys.exit(1)
|
||||
msg[key] = value
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(TIMEOUT)
|
||||
|
||||
Reference in New Issue
Block a user