page_info
Extract page metadata like title, viewport size, fonts, and resource counts to audit web pages without taking screenshots.
Instructions
Get page metadata: title, viewport size, scroll height, fonts, colors, and resource counts. Useful for auditing a page without a full screenshot.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to inspect |
Implementation Reference
- src/index.js:126-164 (handler)The getPageInfo function performs the logic to scrape and return page metadata.
async function getPageInfo(url) { const browser = await getBrowser(); const page = await browser.newPage(); try { await page.setViewport({ width: 1440, height: 900 }); await page.goto(url, { waitUntil: "networkidle2", timeout: 30000 }); const info = await page.evaluate(() => ({ title: document.title, url: window.location.href, viewport: { width: window.innerWidth, height: window.innerHeight, scrollHeight: document.documentElement.scrollHeight, }, meta: { description: document.querySelector('meta[name="description"]')?.content || null, theme: document.querySelector('meta[name="theme-color"]')?.content || null, }, fonts: [...new Set([...document.querySelectorAll("*")].map( (el) => getComputedStyle(el).fontFamily ).filter(Boolean))].slice(0, 10), colors: (() => { const bg = getComputedStyle(document.body).backgroundColor; const fg = getComputedStyle(document.body).color; return { background: bg, foreground: fg }; })(), links: document.querySelectorAll("a").length, images: document.querySelectorAll("img").length, scripts: document.querySelectorAll("script").length, stylesheets: document.querySelectorAll('link[rel="stylesheet"]').length, })); return info; } finally { await page.close(); } } - src/index.js:268-283 (registration)The 'page_info' tool is defined within the ListToolsRequestSchema handler.
{ name: "page_info", description: "Get page metadata: title, viewport size, scroll height, fonts, colors, " + "and resource counts. Useful for auditing a page without a full screenshot.", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to inspect", }, }, required: ["url"], }, }, - src/index.js:330-340 (handler)The case block in the CallToolRequestSchema handler that invokes getPageInfo.
case "page_info": { const info = await getPageInfo(args.url); return { content: [ { type: "text", text: JSON.stringify(info, null, 2), }, ], }; }