Skip to main content
Glama

get_rules

Retrieve accessibility rules for web testing, with options to filter by tags like WCAG standards or best practices, ensuring compliance with Axe-core API and Puppeteer.

Instructions

Get information about available accessibility rules with optional filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagsNoFilter rules by these tags (e.g., "wcag2a", "wcag2aa", "best-practice")

Implementation Reference

  • The handler function for the 'get_rules' tool. It extracts optional 'tags' from input arguments, calls axe.getRules() to fetch accessibility rules (filtered or all), maps them to a simplified structure (ruleId, description, help, helpUrl, tags), and returns formatted JSON content.
    async getRules(args: any) { const { tags } = args; try { // Get the axe rules let rules; if (tags && tags.length > 0) { // Filter rules by tags rules = axe.getRules(tags); } else { // Get all rules rules = axe.getRules(); } return { content: [ { type: 'text', text: JSON.stringify({ rules: rules.map((rule: any) => ({ ruleId: rule.ruleId, description: rule.description, help: rule.help, helpUrl: rule.helpUrl, tags: rule.tags })) }, null, 2), }, ], }; } catch (error) { console.error('[Error] Failed to get rules:', error); throw new McpError( ErrorCode.InternalError, `Failed to get rules: ${error instanceof Error ? error.message : String(error)}` ); } }
  • The input schema definition for the 'get_rules' tool, specifying an optional 'tags' array parameter for filtering rules.
    inputSchema: { type: 'object', properties: { tags: { type: 'array', items: { type: 'string' }, description: 'Filter rules by these tags (e.g., "wcag2a", "wcag2aa", "best-practice")', } },
  • src/index.ts:86-99 (registration)
    Registration of the 'get_rules' tool in the ListTools response, including name, description, and input schema.
    { name: 'get_rules', description: 'Get information about available accessibility rules with optional filtering', inputSchema: { type: 'object', properties: { tags: { type: 'array', items: { type: 'string' }, description: 'Filter rules by these tags (e.g., "wcag2a", "wcag2aa", "best-practice")', } }, }, },
  • src/index.ts:166-167 (registration)
    Dispatch/registration in the CallToolRequestSchema handler switch statement, routing 'get_rules' calls to the getRules method.
    case 'get_rules': return await this.getRules(request.params.arguments);

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