← back to Wallpaper Paint Antics

series2/mcp-proof.mjs

34 lines

// Uses the installed Chrome DevTools MCP collection in its documented isolated mode.
// The shared MCP browser profile belongs to another session; never stop it.
import {Client} from '/Users/macstudio3/.npm/_npx/99e3e8e098e94b9f/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js';
import {StdioClientTransport} from '/Users/macstudio3/.npm/_npx/99e3e8e098e94b9f/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js';
import {ListRootsRequestSchema} from '/Users/macstudio3/.npm/_npx/99e3e8e098e94b9f/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js';
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
const root=import.meta.dirname;
const evidence={tool:'chrome-devtools-mcp',version:'1.8.0',mode:'isolated headless',ticket:'TK-11288',at:new Date().toISOString(),calls:[]};
const client=new Client({name:'wallo-presentation-proof',version:'1.0.0'},{capabilities:{roots:{listChanged:false}}});
client.setRequestHandler(ListRootsRequestSchema,()=>({roots:[{uri:'file://'+root,name:'Wallo and Pippa video project'}]}));
const transport=new StdioClientTransport({command:process.execPath,args:['/Users/macstudio3/.npm/_npx/15c61037b1978c83/node_modules/chrome-devtools-mcp/build/src/bin/chrome-devtools-mcp.js','--isolated','--headless','--no-usage-statistics','--no-performance-crux','--viewport=1440x1400'],stderr:'pipe'});
let stderr='';
async function call(name,args){let result=await client.callTool({name,arguments:args},undefined,{timeout:30000});evidence.calls.push({name,args,result});if(result.isError)throw new Error(JSON.stringify(result));return result;}
try{
 await client.connect(transport);transport.stderr?.on('data',b=>{stderr+=b.toString();});
 const catalog=await client.listTools();evidence.availableTools=catalog.tools.map(x=>x.name);
 const created=await call('new_page',{url:'file://'+path.join(root,'watch.html')});
 const joined=(created.content||[]).filter(c=>c.type==='text').map(c=>c.text).join('\n');
 const match=joined.match(/(?:^|\n)(\d+):[^\n]*\[selected\]/);if(!match)throw new Error('Cannot read page id from '+joined);
 const pageId=Number(match[1]);
 await call('evaluate_script',{pageId,function:'async () => { await Promise.all(Array.from(document.images, img => img.decode())); return {title:document.title, videos:document.querySelectorAll("video").length, products:document.querySelectorAll(".product img").length}; }'});
 const result=await call('evaluate_script',{pageId,function:'async () => { const result=[]; for(const v of document.querySelectorAll("video")){v.muted=true;await v.play(); await new Promise((resolve,reject)=>{let attempts=0;const timer=setInterval(()=>{if(v.currentTime>.4){clearInterval(timer);resolve();}else if(++attempts>150){clearInterval(timer);reject(new Error("Video did not advance: "+v.dataset.slug));}},100);});v.pause();result.push({slug:v.dataset.slug,duration:v.duration,currentTime:v.currentTime,width:v.videoWidth,height:v.videoHeight,error:v.error?.message||null});}return result; }'});
 const serialized=JSON.stringify(result);assert(serialized.includes('04-fire-rated'));assert(serialized.includes('08-service-at-dw'));assert(serialized.includes('wallo-wallcovering-presentation'));
 await call('take_screenshot',{pageId,filePath:path.join(root,'verification','mcp-gallery.png'),fullPage:true});
 // Exercise the chapter navigation in the real review page.
 const chapter=await call('evaluate_script',{pageId,function:'async () => { const v=document.querySelector("#presentation"); v.muted=true; document.querySelector("[data-jump=\\"80\\"]").click(); await new Promise(r=>setTimeout(r,350)); v.pause(); return {time:v.currentTime,links:[...document.querySelectorAll(".product a")].map(a=>a.href)}; }'});
 assert(JSON.stringify(chapter).includes('designerwallcoverings.com/products/'));
 evidence.verdict='PASS';console.log('Chrome DevTools MCP: six video playbacks and chapter navigation PASS.');
}finally{
 await client.close();fs.writeFileSync(path.join(root,'verification','mcp-proof.json'),JSON.stringify(evidence,null,2));fs.writeFileSync(path.join(root,'verification','mcp-stderr.txt'),stderr);
}