Skip to main content
Glama

detox_generate_action

Generate Detox mobile testing actions like tap, type, scroll, and swipe for React Native E2E automation.

Instructions

Generate Detox action code (tap, typeText, scroll, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionTypeYesType of action
elementMatcherYesMatcher code or description
actionParamsNo

Implementation Reference

  • The complete tool object definition for 'detox_generate_action', including its handler function that parses input arguments and generates Detox action code using the generateActionCode helper.
    export const generateActionTool: Tool = {
      name: "detox_generate_action",
      description: "Generate Detox action code (tap, typeText, scroll, etc.).",
      inputSchema: zodToJsonSchema(GenerateActionArgsSchema),
      handler: async (args: z.infer<typeof GenerateActionArgsSchema>) => {
        const parsed = GenerateActionArgsSchema.parse(args);
    
        const code = generateActionCode({
          actionType: parsed.actionType,
          elementMatcher: parsed.elementMatcher,
          params: parsed.actionParams,
        });
    
        return {
          success: true,
          code,
        };
      },
    };
  • Zod schema defining the input parameters for the detox_generate_action tool, used for validation and JSON schema conversion.
    export const GenerateActionArgsSchema = z.object({
      actionType: z
        .enum([
          "tap",
          "multiTap",
          "longPress",
          "typeText",
          "replaceText",
          "clearText",
          "scroll",
          "scrollTo",
          "swipe",
          "pinch",
        ])
        .describe("Type of action"),
      elementMatcher: z.string().describe("Matcher code or description"),
      actionParams: z
        .object({
          text: z.string().optional(),
          times: z.number().optional(),
          duration: z.number().optional(),
          direction: z.enum(["up", "down", "left", "right"]).optional(),
          speed: z.enum(["fast", "slow"]).optional(),
          offset: z.number().optional(),
          edge: z.enum(["top", "bottom", "left", "right"]).optional(),
        })
        .optional(),
    });
    
    export type GenerateActionArgs = z.infer<typeof GenerateActionArgsSchema>;
  • The allTools array exports all MCP tools, registering 'detox_generate_action' (via generateActionTool) for use in the protocol.
    export const allTools: Tool[] = [
      buildTool,
      testTool,
      initTool,
      readConfigTool,
      listConfigurationsTool,
      validateConfigTool,
      createConfigTool,
      listDevicesTool,
      generateTestTool,
      generateMatcherTool,
      generateActionTool,
      generateExpectationTool,
    ];
  • Core helper function generateActionCode that generates the specific Detox action code snippet invoked by the tool handler.
    export function generateActionCode(options: {
      actionType:
        | "tap"
        | "multiTap"
        | "longPress"
        | "typeText"
        | "replaceText"
        | "clearText"
        | "scroll"
        | "scrollTo"
        | "swipe"
        | "pinch";
      elementMatcher: string;
      params?: {
        text?: string;
        times?: number;
        duration?: number;
        direction?: "up" | "down" | "left" | "right";
        speed?: "fast" | "slow";
        offset?: number;
        edge?: "top" | "bottom" | "left" | "right";
        point?: { x: number; y: number };
      };
    }): string {
      const element = options.elementMatcher;
      const p = options.params || {};
    
      switch (options.actionType) {
        case "tap":
          if (p.point) {
            return `await ${element}.tap({ x: ${p.point.x}, y: ${p.point.y} });`;
          }
          return `await ${element}.tap();`;
    
        case "multiTap":
          return `await ${element}.multiTap(${p.times || 2});`;
    
        case "longPress":
          if (p.duration) {
            return `await ${element}.longPress(${p.duration});`;
          }
          return `await ${element}.longPress();`;
    
        case "typeText":
          return `await ${element}.typeText('${p.text || ""}');`;
    
        case "replaceText":
          return `await ${element}.replaceText('${p.text || ""}');`;
    
        case "clearText":
          return `await ${element}.clearText();`;
    
        case "scroll":
          const scrollOffset = p.offset || 200;
          const scrollDir = p.direction || "down";
          return `await ${element}.scroll(${scrollOffset}, '${scrollDir}');`;
    
        case "scrollTo":
          const edge = p.edge || "bottom";
          return `await ${element}.scrollTo('${edge}');`;
    
        case "swipe":
          const swipeDir = p.direction || "up";
          const speed = p.speed || "fast";
          return `await ${element}.swipe('${swipeDir}', '${speed}');`;
    
        case "pinch":
          const scale = p.offset || 2;
          return `await ${element}.pinch(${scale});`;
    
        default:
          return `await ${element}.tap();`;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool generates code, implying a read-only or creation operation, but doesn't disclose behavioral traits like whether it modifies files, requires specific inputs, or has side effects. This is inadequate for a tool with parameters and no 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 that front-loads the core purpose. Every word earns its place, with no wasted text, making it highly concise and well-structured.

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 tool has 3 parameters, 67% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't explain what the generated code looks like, how it's used, or the role of actionParams, leaving significant gaps for an AI agent to understand the tool's full context.

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?

Schema description coverage is 67%, with parameters like actionType and elementMatcher described in the schema. The description adds minimal value by listing example action types (e.g., tap, typeText, scroll), which partially overlaps with the enum in the schema. It doesn't explain the purpose of actionParams or provide additional semantics beyond the schema.

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 verb 'Generate' and the resource 'Detox action code', specifying it produces code for actions like tap, typeText, scroll, etc. It distinguishes from siblings like detox_generate_expectation or detox_generate_test by focusing on actions, but doesn't explicitly contrast them.

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?

No guidance is provided on when to use this tool versus alternatives such as detox_generate_test or detox_generate_matcher. The description implies usage for generating action code, but lacks explicit context, prerequisites, or exclusions.

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/gayancliyanage/detox-mcp'

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