← Files Sulekha EventsARCHIVED FILE
source/scripts/verify-live.js
3.01 KB · Nov 30, 2026 · 07:53 UTC
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const base = process.argv[2];
if (!base) throw new Error("Usage: npm run verify:live -- https://your-app-host");
const url = new URL(base);
if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1") {
throw new Error("Use the public HTTPS app URL.");
}
const timeout = setTimeout(() => { console.error("Verification timed out."); process.exit(1); }, 60000);
const client = new Client({ name: "sulekha-release-check", version: "0.4.6" });
try {
const response = await fetch(new URL("/health", url), { signal: AbortSignal.timeout(15000) });
if (!response.ok) throw new Error(`Health returned HTTP ${response.status}`);
const health = await response.json();
if (health.version !== "0.4.6" || health.build !== "apps-sdk-widget-11") throw new Error("Azure is not serving the current build.");
console.log("Current deployment is running.");
await client.connect(new StreamableHTTPClientTransport(new URL("/mcp", url)));
const { tools } = await client.listTools();
if (tools.length !== 1 || tools[0].name !== "search_sulekha_events") throw new Error("Unexpected tools.");
const { resources } = await client.listResources();
const widget = await client.readResource({ uri: resources[0].uri });
if (!widget.contents[0]._meta?.["openai/widgetDomain"]) throw new Error("Set WIDGET_DOMAIN before submission.");
const html = widget.contents[0].text;
if (/<script[^>]*\bsrc=/i.test(html)) throw new Error("Widget still depends on an external startup script.");
const embeddedScript = html.match(/<script>([\s\S]*?)<\/script>/i)?.[1];
if (!embeddedScript?.includes('initializeBridge') || html.includes('__WIDGET_SCRIPT')) throw new Error("Embedded widget startup code is missing.");
if (tools[0]._meta?.ui?.resourceUri !== 'ui://sulekha/events-v20.html') throw new Error("Widget metadata is outdated.");
const result = await client.callTool({ name: "search_sulekha_events", arguments: { query: "", rawQuery: "show me events in NJ", stateCode: "NJ", latitude: 40.5187, longitude: -74.4121, distance: 100, limit: 3 } });
if (result.isError) throw new Error(result.content?.[0]?.text ?? "Event search failed.");
const events = result.structuredContent.events;
if (!events.length || events.some(event => event.region !== 'NJ')) throw new Error("NJ smoke search returned no events or another state.");
const poster = events.find(event => event.imageUrl)?.imageUrl;
if (!poster) throw new Error("NJ smoke search returned no poster images.");
const image = await fetch(poster, { signal: AbortSignal.timeout(10000) });
if (!image.ok || !image.headers.get('content-type')?.startsWith('image/')) throw new Error("Poster image is unavailable.");
await image.body?.cancel();
console.log(`MCP, UI metadata and live upstream search passed (${result.structuredContent.count} results).`);
} finally {
clearTimeout(timeout);
await client.close();
}
SHA-256: 3d40b1524f397834821597607a5edec66d3288e0e426c1a73c706ecc371f9f69