1import { Client } from "@modelcontextprotocol/sdk/client/index.js";2import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";34const url = new URL(process.env.MCPSWEEPER_URL ?? "http://127.0.0.1:8787/mcp");5const client = new Client({ name: "mcpsweeper-smoke", version: "0.1.0" });67try {8 await client.connect(new StreamableHTTPClientTransport(url));9 const tools = await client.listTools();10 const resources = await client.listResources();11 const started = await client.callTool({12 name: "start_game",13 arguments: { size: 16, density: 0.1, seed: "smoke-test" },14 });15 const gameId = started.structuredContent?.game_id;16 if (typeof gameId !== "string") throw new Error("start_game did not return a game_id");1718 const observed = await client.callTool({ name: "observe_game", arguments: { game_id: gameId } });19 const app = await client.readResource({ uri: "ui://mcpsweeper/spectator.html" });2021 console.log(22 JSON.stringify(23 {24 tools: tools.tools.map((tool) => tool.name),25 resources: resources.resources.map((resource) => resource.uri),26 game_id: gameId,27 board_size: observed.structuredContent?.position?.width,28 app_html_bytes: app.contents[0]?.text?.length ?? 0,29 },30 null,31 2,32 ),33 );34} finally {35 await client.close();36}