run_nextjs_audit
Perform a Next.js-specific audit on web pages to identify performance, SEO, and accessibility issues, enabling optimization for ARM64 devices like Raspberry Pi.
Instructions
Run a Next.js specific audit on the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:988-1027 (handler)Core handler function that executes the Next.js audit by evaluating a JavaScript expression in the browser context to check for Next.js-specific elements and best practices like __NEXT_DATA__, next/image usage, Link components, and Head usage.async runNextJSAudit() { await this.ensureChromium(); const result = await this.sendCDPCommand('Runtime.evaluate', { expression: ` const results = []; const nextData = document.querySelector('#__NEXT_DATA__'); if (!nextData) { results.push('This does not appear to be a Next.js application'); JSON.stringify(results); } else { const nextImages = document.querySelectorAll('img[data-nimg]'); const regularImages = document.querySelectorAll('img:not([data-nimg])'); if (regularImages.length > 0 && nextImages.length === 0) { results.push(\`Consider using Next.js Image component for \${regularImages.length} images\`); } const internalLinks = Array.from(document.querySelectorAll('a[href^="/"]')).length; if (internalLinks > 0) { results.push(\`Found \${internalLinks} internal links - ensure Next.js Link component is used\`); } const headTags = document.querySelectorAll('meta, title, link[rel="stylesheet"]'); if (headTags.length < 3) { results.push('Consider using Next.js Head component for better SEO'); } JSON.stringify(results.length > 0 ? results : ['Next.js specific checks passed']); } `, returnByValue: true }); const nextjsResults = JSON.parse(result.result?.value || '[]'); return { content: [{ type: 'text', text: `Next.js Audit Results:\\n${nextjsResults.join('\\n')}` }], }; }
- index.js:311-318 (registration)Tool registration entry in the MCP tools array, defining the tool name, description, and input schema (empty object).{ name: 'run_nextjs_audit', description: 'Run a Next.js specific audit on the current page', inputSchema: { type: 'object', properties: {}, }, },
- index.js:387-388 (registration)Dispatch logic in the request handler switch statement that maps the tool name to the runNextJSAudit method call.case 'run_nextjs_audit': return await this.runNextJSAudit();
- index.js:314-317 (schema)Input schema definition for the tool (accepts no parameters).inputSchema: { type: 'object', properties: {}, },
- index.js:1068-1068 (helper)Usage of the handler within the comprehensive runAuditMode tool.results.nextjs = await this.runNextJSAudit();