Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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();
  • Input schema definition for the tool (empty object, no parameters required).
    inputSchema: {
      type: 'object',
      properties: {},
    },
  • Usage of the tool handler within the comprehensive runAuditMode method.
    results.nextjs = await this.runNextJSAudit();
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe behavioral traits like whether it modifies the page, requires specific page states, returns results, or has side effects. This is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an audit tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the audit entails, what results to expect, or how it interacts with the page, leaving significant gaps in understanding for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter semantics, so it meets the baseline of 4 for tools with no parameters, as there's nothing to compensate for.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run') and target ('Next.js specific audit on the current page'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling audit tools like 'run_accessibility_audit' or 'run_seo_audit' beyond mentioning 'Next.js specific', which is helpful but not a full differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like other audit tools (e.g., 'run_accessibility_audit', 'run_seo_audit') or general audit modes (e.g., 'run_audit_mode'). It lacks explicit when/when-not instructions or prerequisite context, such as needing a Next.js page to be loaded.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nfodor/claude-arm64-browser'

If you have feedback or need assistance with the MCP directory API, please join our Discord server