from __future__ import annotations import contextvars import json import uuid from typing import Any from mcp.server.mcpserver import MCPServer from app.adb_lan.controller import LanAdbController from app.bridge.manager import DeviceBridgeManager from app.storage.db import PulseWallDB, now_ms # Populated by ASGI middleware on /mcp to verify whether the caller is on private LAN. mcp_request_is_lan: contextvars.ContextVar[bool] = contextvars.ContextVar("mcp_request_is_lan", default=False) UI_FRAMEWORK_GUIDE = { "local_assets_base": "https://appassets.androidplatform.net/assets/pulsewall/", "preloaded_globals": [ "Vue (Vue 3 runtime)", "dayjs (Day.js datetime ~2KB)", "PwIcons (ultra-light offline SVG icons: PwIcons.svg('cpu', 20) or )", "pulsewall-tokens.css + tailwind-lite.min.css (zero-runtime Tailwind utility classes & dark-glass tokens)", "window.PulseWall JSBridge: loadLib(nameOrArray), sendAction(id, label, customText), getDeviceProfile(), getTelemetry(), getDataContext()", ], "lazy_local_libraries": { "usage": "Call `await window.PulseWall.loadLib(['plyr', 'hls'])` (or `