run_nextjs_audit
Audit Next.js applications to identify performance, security, and optimization issues for improved web application quality.
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)Main handler function that runs Next.js specific audits by evaluating JavaScript in the browser context via CDP to check for __NEXT_DATA__, Image component 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 object defining the 'run_nextjs_audit' tool with description and empty input schema.{ name: 'run_nextjs_audit', description: 'Run a Next.js specific audit on the current page', inputSchema: { type: 'object', properties: {}, }, },
- index.js:386-388 (registration)Dispatch case in the CallToolRequestHandler switch statement that routes the tool call to the runNextJSAudit method.return await this.runBestPracticesAudit(); case 'run_nextjs_audit': return await this.runNextJSAudit();
- index.js:314-317 (schema)Input schema definition for the tool (empty object, no parameters required).inputSchema: { type: 'object', properties: {}, },
- index.js:1068-1068 (helper)Usage of the tool handler within the comprehensive runAuditMode method.results.nextjs = await this.runNextJSAudit();