Skip to main content
Glama

accessibility_audit

Audit the current screen for accessibility violations, including missing labels, small tap targets, and images without alt text, and receive a detailed report.

Instructions

Verifie l'accessibilite de l'ecran actuel : labels manquants, tap targets trop petits, images sans alt text. Retourne un rapport de violations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler function that performs the accessibility audit. It resolves the device, gets the UI tree (iOS via WDA or Android via adb), runs audit checks on all elements, and returns a formatted report of violations.
    export function registerAccessibilityAudit(server: McpServer): void {
      server.tool(
        "accessibility_audit",
        "Verifie l'accessibilite de l'ecran actuel : labels manquants, tap targets trop petits, images sans alt text. Retourne un rapport de violations.",
        {},
        async () => {
          const result = await resolveDevice();
          if ("error" in result) return { content: [{ type: "text", text: result.error }], isError: true };
          const dev = result.device;
    
          try {
            let elements: ParsedElement[];
    
            if (dev.platform === "ios") {
              const wda = await ensureWdaRunning(dev);
              if (!wda.ready) return { content: [{ type: "text", text: wda.message ?? "WDA indisponible." }], isError: true };
              elements = await iosGetUiTree();
            } else {
              elements = await androidGetUiTree();
            }
    
            if (elements.length === 0) {
              return {
                content: [{ type: "text", text: `Accessibility Audit — ${dev.name} (${dev.platform})\n\nWARNING — Aucun élément détecté. L'écran semble vide ou en transition. Réessaie après le chargement.` }],
                isError: true,
              };
            }
    
            const violations = auditElements(elements, dev.platform);
            const errors = violations.filter((v) => v.severity === "error");
            const warnings = violations.filter((v) => v.severity === "warning");
    
            const lines: string[] = [
              `Accessibility Audit — ${dev.name} (${dev.platform})`,
              `Éléments analysés : ${elements.length}`,
              "",
            ];
    
            if (violations.length === 0) {
              lines.push("PASS — Aucune violation détectée.");
            } else {
              lines.push(`VIOLATIONS (${violations.length}) :`);
              lines.push("");
    
              for (const v of violations) {
                const icon = v.severity === "error" ? "[ERROR]" : "[WARNING]";
                lines.push(`${icon} ${v.check} : ${v.message} — ${v.element}`);
              }
    
              lines.push("");
              lines.push(`Resume : ${errors.length} erreur(s), ${warnings.length} avertissement(s), ${elements.length - violations.length} element(s) OK`);
            }
    
            logAction("accessibility_audit", `${violations.length} violation(s) trouvée(s)`, errors.length > 0, dev.platform, dev.id, dev.name);
            return {
              content: [{ type: "text", text: lines.join("\n") }],
              isError: errors.length > 0,
            };
          } catch (err) {
            const msg = err instanceof Error ? err.message : String(err);
            return { content: [{ type: "text", text: `Erreur accessibility_audit: ${msg}` }], isError: true };
          }
        }
      );
  • Core audit logic: checks interactive elements for missing labels (A), tap targets too small (B), and images without alt text (C). Returns a list of Violations with severity grading.
    function auditElements(elements: ParsedElement[], platform: "ios" | "android"): Violation[] {
      const violations: Violation[] = [];
      const minTap = platform === "ios" ? IOS_MIN_TAP : ANDROID_MIN_TAP;
    
      for (const el of elements) {
        const displayText = el.label || el.name || el.value || "";
        const pos = `(${el.x},${el.y} ${el.width}x${el.height})`;
    
        // Check A — Interactive elements without labels
        if (isInteractive(el.type, platform)) {
          if (!el.label && !el.name && !el.value) {
            violations.push({
              severity: "error",
              check: "missing-label",
              message: `${el.type} sans texte accessible`,
              element: `${el.type} ${pos}`,
              position: pos,
            });
          }
    
          // Check B — Tap target too small
          if (el.width < minTap || el.height < minTap) {
            const severity = el.width < minTap * 0.75 || el.height < minTap * 0.75 ? "error" : "warning";
            violations.push({
              severity,
              check: "tap-target-small",
              message: `${el.type} "${displayText}" trop petit : ${el.width}x${el.height} (min ${minTap}x${minTap})`,
              element: `${el.type} "${displayText}" ${pos}`,
              position: pos,
            });
          }
        }
    
        // Check C — Images without alt text
        if (isImage(el.type, platform)) {
          if (!el.label && !el.name && !el.value) {
            violations.push({
              severity: "warning",
              check: "image-no-alt",
              message: `Image sans texte alternatif`,
              element: `${el.type} ${pos}`,
              position: pos,
            });
          }
        }
      }
    
      return violations;
    }
  • The Violation interface defining the structure of each audit finding with severity, check name, message, element description, and position.
    interface Violation {
      severity: "error" | "warning";
      check: string;
      message: string;
      element: string;
      position: string;
    }
  • Platform-specific sets for interactive element types and image types, plus minimum tap target sizes (44px for iOS, 48px for Android).
    // Interactive element types per platform
    const IOS_INTERACTIVE = new Set(["Button", "TextField", "SecureTextField", "Switch", "Slider", "Stepper", "Link", "SearchField", "SegmentedControl"]);
    const ANDROID_INTERACTIVE = new Set(["Button", "EditText", "CheckBox", "RadioButton", "Switch", "SeekBar", "ImageButton", "ToggleButton", "FloatingActionButton"]);
    
    // Image types per platform
    const IOS_IMAGE = new Set(["Image"]);
    const ANDROID_IMAGE = new Set(["ImageView", "ImageButton"]);
    
    // Minimum tap target sizes
    const IOS_MIN_TAP = 44;
    const ANDROID_MIN_TAP = 48;
  • src/index.ts:22-70 (registration)
    Import and registration of the accessibility_audit tool on line 22 (import) and line 67 (registration call).
    import { registerAccessibilityAudit } from "./tools/accessibility-audit.js";
    import { registerTestReport } from "./tools/test-report.js";
    import { registerVisualDiff } from "./tools/visual-diff.js";
    import { registerMultiDevice } from "./tools/multi-device.js";
    
    const server = new McpServer({
      name: "phantom",
      version: "2.3.0",
    });
    
    // Device management
    registerListDevices(server);
    registerSetDevice(server);
    registerPrepareDevice(server);
    
    // Observation
    registerScreenshot(server);
    registerGetUiTree(server);
    registerWaitForElement(server);
    registerScrollUntilVisible(server);
    
    // Assertions
    registerAssertVisible(server);
    registerAssertNotVisible(server);
    
    // Interaction
    registerTap(server);
    registerLongPress(server);
    registerTypeText(server);
    registerSwipe(server);
    registerDismissKeyboard(server);
    
    // Navigation
    registerDeepLink(server);
    
    // Device actions
    registerShake(server);
    registerRotate(server);
    registerVideoRecord(server);
    
    // App lifecycle
    registerLaunchApp(server);
    registerKillApp(server);
    
    // Tier 3 — Analysis & Automation
    registerAccessibilityAudit(server);
    registerTestReport(server);
    registerVisualDiff(server);
    registerMultiDevice(server);
Behavior3/5

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

With no annotations, the description must cover behavioral traits. It implies a read-only audit by stating 'checks' and 'returns a report', but does not explicitly confirm no side effects or disclose any constraints like requiring a stable screen.

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 sentence that efficiently conveys the tool's function, key checks, and output. No unnecessary words.

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

Completeness4/5

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

For a tool with no parameters and no output schema, the description is adequate. It explains the input (current screen), the checks performed, and the return type. Minor omission: it does not specify the format or structure of the violation report, but that might be implied.

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 input schema has 0 parameters, so schema description coverage is 100%. Per the rubric, 0 parameters earns a baseline of 4. The description adds no parameter information, which is unnecessary.

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

Purpose5/5

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

The description clearly states the tool's purpose: checking accessibility of the current screen for missing labels, small tap targets, and missing alt text, and returning a violation report. This distinguishes it from sibling tools, which are all UI interaction or device manipulation tools.

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

Usage Guidelines3/5

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

The description implies usage for accessibility verification but does not explicitly state when to use it vs. alternatives or when not to use it. No exclusions or context are provided.

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/nthImpulse/phantom-mcp'

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