from __future__ import annotations from typing import Any from urllib.request import urlopen import json def list_strategies(base_url: str) -> list[dict[str, Any]]: root = base_url.rstrip('/') if root.endswith('/mcp/sse'): root = root[:-8] with urlopen(f"{root}/strategies", timeout=10) as resp: payload = json.loads(resp.read().decode("utf-8")) strategies = payload.get("configured", []) or [] return [s for s in strategies if isinstance(s, dict)] def list_accounts(base_url: str) -> list[dict[str, Any]]: root = base_url.rstrip('/') if root.endswith('/mcp/sse'): root = root[:-8] with urlopen(f"{root}/accounts", timeout=10) as resp: payload = json.loads(resp.read().decode("utf-8")) accounts = payload.get("accounts", []) or [] return [a for a in accounts if isinstance(a, dict)]