11 lines
497 B
Python
11 lines
497 B
Python
"""Reads JSON-encoded string from stdin (the kind MCP returns when wrapping a string),
|
|
and writes the decoded value as UTF-8 to the given file."""
|
|
import json, sys, os
|
|
out_path = sys.argv[1]
|
|
raw = sys.stdin.read()
|
|
# raw is a JSON string like "[{\"name\":\"...\"}]" — already JSON-quoted
|
|
decoded = json.loads(raw)
|
|
os.makedirs(os.path.dirname(out_path) or '.', exist_ok=True)
|
|
with open(out_path, 'w', encoding='utf-8') as f:
|
|
f.write(decoded)
|
|
print(f'wrote {out_path} ({len(decoded)} chars)')
|