import json
import sys
import os

# Since we have the tool schema, we can call it via subprocess
# But let's try using curl with Trello API directly if we have env vars

# Check environment variables for Trello
key = os.environ.get('TRELLO_KEY')
token = os.environ.get('TRELLO_TOKEN')

if not key or not token:
    print("ERROR: TRELLO_KEY and TRELLO_TOKEN env vars not set", file=sys.stderr)
    sys.exit(1)

import urllib.request
import urllib.parse

card_id = "6a1d64126a923744238639f9"
url = f"https://api.trello.com/1/cards/{card_id}?key={key}&token={token}&fields=desc"

try:
    with urllib.request.urlopen(url) as response:
        data = json.loads(response.read().decode())
        print(json.dumps(data, indent=2))
except Exception as e:
    print(f"ERROR: {e}", file=sys.stderr)
    sys.exit(1)
