Skip to main content
Glama

assert_not_visible

Confirm that an element with specified text is not visible on screen. Validate hidden or absent UI components.

Instructions

Vérifie qu'un élément contenant le texte donné n'est PAS visible à l'écran.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesTexte qui ne doit PAS être à l'écran

Implementation Reference

  • The main handler implementation for 'assert_not_visible'. It registers the tool on the MCP server, resolves the device, fetches the UI tree (iOS via WDA or Android via ADB), and uses matchElementByText to check if the given text is NOT visible. Returns PASS if not found, FAIL if found.
    export function registerAssertNotVisible(server: McpServer): void {
      server.tool(
        "assert_not_visible",
        "Vérifie qu'un élément contenant le texte donné n'est PAS visible à l'écran.",
        {
          text: z.string().describe("Texte qui ne doit PAS être à l'écran"),
        },
        async ({ text }) => {
          const result = await resolveDevice();
          if ("error" in result) return { content: [{ type: "text", text: result.error }], isError: true };
          const dev = result.device;
    
          if (dev.platform === "ios") {
            const wda = await ensureWdaRunning(dev);
            if (!wda.ready) return { content: [{ type: "text", text: wda.message ?? "WDA indisponible." }], isError: true };
          }
    
          try {
            const elements = dev.platform === "ios"
              ? await iosGetUiTree()
              : await androidGetUiTree();
    
            const found = matchElementByText(elements, text);
    
            if (!found) {
              const passMsg = `PASS — "${text}" n'est pas visible (attendu).`;
              logAction("assert_not_visible", passMsg, false, dev.platform, dev.id, dev.name);
              return { content: [{ type: "text", text: passMsg }] };
            }
    
            const displayText = found.label || found.name || found.value || "";
            const failMsg = `FAIL — "${text}" est visible : ${found.type} "${displayText}" à (${found.x},${found.y}). Il ne devrait pas l'être.`;
            logAction("assert_not_visible", failMsg, true, dev.platform, dev.id, dev.name);
            return {
              content: [{ type: "text", text: failMsg }],
              isError: true,
            };
          } catch (err) {
            const msg = err instanceof Error ? err.message : String(err);
            return { content: [{ type: "text", text: `Erreur assert: ${msg}` }], isError: true };
          }
        }
      );
    }
  • The tool schema definition for 'assert_not_visible': accepts a required 'text' string parameter describing the text that should not be on screen.
    export function registerAssertNotVisible(server: McpServer): void {
      server.tool(
        "assert_not_visible",
        "Vérifie qu'un élément contenant le texte donné n'est PAS visible à l'écran.",
        {
          text: z.string().describe("Texte qui ne doit PAS être à l'écran"),
  • src/index.ts:18-45 (registration)
    Import of registerAssertNotVisible from ./tools/assert.ts, and call to registerAssertNotVisible(server) at line 45 to register this tool on the MCP server.
    import { registerAssertVisible, registerAssertNotVisible } from "./tools/assert.js";
    import { registerDeepLink } from "./tools/deep-link.js";
    import { registerVideoRecord } from "./tools/video-record.js";
    import { registerShake, registerRotate } from "./tools/device-actions.js";
    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);
  • The 'assert_not_visible' tool is listed in ALWAYS_SCREENSHOT_TOOLS set, ensuring a screenshot is always captured when this tool is used for auto-reporting.
    const ALWAYS_SCREENSHOT_TOOLS = new Set(["assert_visible", "assert_not_visible", "accessibility_audit", "launch_app"]);
Behavior3/5

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

With no annotations, the description carries full burden. It accurately describes the behavior (verifying non-visibility) but does not disclose potential error conditions (e.g., what happens if element is visible) or side effects.

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, compact sentence that conveys the core purpose without extraneous words. It is front-loaded with the verb and resource.

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 simple assertion tool with one parameter and no output schema, the description is minimally adequate. It explains the check but does not elaborate on return type or usage in testing flows.

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

Parameters3/5

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

The schema provides 100% coverage for the single parameter with a clear description. The tool description adds no additional meaning beyond what the schema already states.

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 action (vérifie), resource (élément contenant le texte donné), and condition (n'est PAS visible). It effectively distinguishes from the sibling assert_visible by specifying negation.

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 asserting element absence but lacks explicit when-to-use, when-not-to-use, or reference to alternatives like assert_visible. The contrast with the sibling is implicit but not stated.

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