Skip to main content
Glama

test_accessibility

Evaluate webpage accessibility compliance with WCAG standards using Axe-core. Analyze specific accessibility tags to identify and address issues effectively.

Instructions

Test a webpage for accessibility issues using Axe-core

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagsNoOptional array of accessibility tags to test (e.g., "wcag2a", "wcag2aa", "wcag21a")
urlYesURL of the webpage to test

Implementation Reference

  • src/index.ts:46-65 (registration)
    Registration of the 'test_accessibility' tool in the MCP ListTools handler, defining its name, description, and input schema.
    {
      name: 'test_accessibility',
      description: 'Test a webpage for accessibility issues using Axe-core',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL of the webpage to test',
          },
          tags: {
            type: 'array',
            items: { type: 'string' },
            description: 'Optional array of accessibility tags to test (e.g., "wcag2a", "wcag2aa", "wcag21a")',
            default: ['wcag2aa']
          }
        },
        required: ['url'],
      },
    },
  • The main handler function for 'test_accessibility' tool. Launches Puppeteer browser, navigates to the provided URL, runs Axe accessibility analysis (optionally filtered by tags), formats results, and returns as MCP content.
    async testAccessibility(args: any) {
      const { url, tags } = args;
    
      if (!url) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameter: url'
        );
      }
    
      let browser;
      try {
        browser = await puppeteer.launch({
          headless: true,
          args: ['--no-sandbox', '--disable-setuid-sandbox']
        });
        const page = await browser.newPage();
        
        // Set a reasonable viewport
        await page.setViewport({ width: 1280, height: 800 });
        
        await page.goto(url, { waitUntil: 'networkidle0', timeout: 0 });
        
        // Run axe analysis
        const axe = new AxePuppeteer(page);
        
        if (tags && tags.length > 0) {
          axe.withTags(tags);
        }
        
        const result = await axe.analyze();
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(this.formatResults(result), null, 2),
            },
          ],
        };
      } finally {
        if (browser) {
          await browser.close();
        }
      }
    }
  • Helper function used by the test_accessibility handler to format AxeResults into a structured JSON response with violations, passes, and metadata.
    private formatResults(result: AxeResults) {
      return {
        violations: result.violations.map((violation: Result) => ({
          id: violation.id,
          impact: violation.impact || 'unknown',
          description: violation.description,
          help: violation.help,
          helpUrl: violation.helpUrl,
          affectedNodes: violation.nodes.map((node: NodeResult) => ({
            html: node.html,
            target: node.target,
            failureSummary: node.failureSummary || ''
          }))
        })),
        passes: result.passes.length,
        incomplete: result.incomplete.length,
        inapplicable: result.inapplicable.length,
        timestamp: result.timestamp,
        url: result.url,
        testEngine: {
          name: result.testEngine.name,
          version: result.testEngine.version
        },
        testRunner: result.testRunner,
        testEnvironment: result.testEnvironment,
      };
    }
Install Server

Other Tools

Related 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/ronantakizawa/a11ymcp'

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