Skip to main content
Glama

detox_build

Build mobile apps for Detox end-to-end testing by executing configured build commands to prepare applications for React Native testing scenarios.

Instructions

Build the app for Detox testing. Runs the build command from your Detox configuration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configurationNoDevice configuration name
configPathNoPath to Detox config file
ifMissingNoOnly build if app binary is missing
silentNoDon't fail if no build command exists
cwdNoWorking directory

Implementation Reference

  • The complete tool definition for 'detox_build', including the handler function that parses input arguments and executes the 'detox build' CLI command via executeDetoxCommand.
    export const buildTool: Tool = {
      name: "detox_build",
      description: "Build the app for Detox testing. Runs the build command from your Detox configuration.",
      inputSchema: zodToJsonSchema(BuildArgsSchema),
      handler: async (args: z.infer<typeof BuildArgsSchema>) => {
        const parsed = BuildArgsSchema.parse(args);
        const cliArgs: string[] = ["build"];
    
        if (parsed.configuration) {
          cliArgs.push("-c", parsed.configuration);
        }
        if (parsed.configPath) {
          cliArgs.push("-C", parsed.configPath);
        }
        if (parsed.ifMissing) {
          cliArgs.push("--if-missing");
        }
        if (parsed.silent) {
          cliArgs.push("--silent");
        }
    
        const result = await executeDetoxCommand(cliArgs, { cwd: parsed.cwd });
    
        return {
          success: result.success,
          output: result.stdout,
          errors: result.stderr,
          duration: `${(result.duration / 1000).toFixed(1)}s`,
        };
      },
    };
  • Zod schema defining the input parameters for the detox_build tool.
    export const BuildArgsSchema = z.object({
      configuration: z.string().optional().describe("Device configuration name"),
      configPath: z.string().optional().describe("Path to Detox config file"),
      ifMissing: z.boolean().optional().default(false).describe("Only build if app binary is missing"),
      silent: z.boolean().optional().default(false).describe("Don't fail if no build command exists"),
      cwd: z.string().optional().describe("Working directory"),
    });
  • Helper function that executes the Detox CLI command by spawning 'npx detox' process, captures stdout/stderr, handles timeout and errors, used by detox_build handler.
    export async function executeDetoxCommand(
      args: string[],
      options: ExecutionOptions = {}
    ): Promise<ExecutionResult> {
      const startTime = Date.now();
      const cwd = options.cwd || process.cwd();
      const timeout = options.timeout || 300000; // 5 minutes default
    
      return new Promise((resolve) => {
        const proc = spawn("npx", ["detox", ...args], {
          cwd,
          shell: true,
          env: { ...process.env, ...options.env },
        });
    
        let stdout = "";
        let stderr = "";
    
        proc.stdout.on("data", (data) => {
          stdout += data.toString();
        });
    
        proc.stderr.on("data", (data) => {
          stderr += data.toString();
        });
    
        const timeoutId = setTimeout(() => {
          proc.kill("SIGTERM");
          resolve({
            success: false,
            stdout,
            stderr: stderr + "\nProcess timed out",
            exitCode: null,
            duration: Date.now() - startTime,
          });
        }, timeout);
    
        proc.on("close", (code) => {
          clearTimeout(timeoutId);
          resolve({
            success: code === 0,
            stdout,
            stderr,
            exitCode: code,
            duration: Date.now() - startTime,
          });
        });
    
        proc.on("error", (error) => {
          clearTimeout(timeoutId);
          resolve({
            success: false,
            stdout,
            stderr: error.message,
            exitCode: null,
            duration: Date.now() - startTime,
          });
        });
      });
    }
  • Registration of detox_build as part of the allTools array exported for use in MCP server.
    export const allTools: Tool[] = [
      buildTool,
      testTool,
      initTool,
      readConfigTool,
      listConfigurationsTool,
      validateConfigTool,
      createConfigTool,
      listDevicesTool,
      generateTestTool,
      generateMatcherTool,
      generateActionTool,
      generateExpectationTool,
    ];
  • src/index.ts:50-94 (registration)
    MCP server request handler for calling tools, which finds and executes the detox_build handler when requested.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      const tool = allTools.find((t) => t.name === name);
      if (!tool) {
        throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
      }
    
      try {
        // Add project path to args if not specified
        const argsWithPath = {
          ...args,
          cwd: (args as any)?.cwd || PROJECT_PATH,
          projectPath: (args as any)?.projectPath || PROJECT_PATH,
        };
    
        const result = await tool.handler(argsWithPath);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: false,
                  error: error.message,
                },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    });
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 of behavioral disclosure. It mentions running a build command but fails to detail critical behaviors such as whether it modifies files, requires specific permissions, handles errors, or produces output. For a build tool with potential side effects, this omission is significant and leaves the agent guessing about its operational impact.

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 highly concise and front-loaded, consisting of two sentences that directly state the tool's purpose and action without unnecessary details. Every sentence earns its place by clearly conveying core functionality, making it efficient and easy to understand at a glance.

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 complexity of a build tool with no annotations and no output schema, the description is incomplete. It lacks information on behavioral traits, error handling, output format, and integration with sibling tools. This makes it inadequate for an agent to fully understand how to invoke and interpret results, especially in a testing context where build outcomes are critical.

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 input schema has 100% description coverage, providing clear documentation for all 5 parameters. The description does not add any semantic details beyond what the schema already explains, such as how parameters interact or typical use cases. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 tool's purpose with a specific verb ('Build') and resource ('the app for Detox testing'), and it explains the action ('Runs the build command from your Detox configuration'). However, it does not explicitly distinguish this tool from its siblings, such as detox_test or detox_init, which might also involve building or configuration steps, leaving room for ambiguity.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing a Detox config file), exclusions, or comparisons to sibling tools like detox_test (which might include building) or detox_list_configurations (for checking available builds). This lack of context makes it unclear when this tool is the appropriate choice.

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