Skip to main content
Glama

detox_init

Initialize end-to-end testing for React Native projects by creating folder structure and configuration for the Detox framework.

Instructions

Initialize Detox in a React Native project. Creates e2e folder structure and configuration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to React Native project root
testRunnerNojest

Implementation Reference

  • Complete definition of the detox_init tool, including its handler function that executes the Detox 'init' CLI command with optional testRunner argument.
    export const initTool: Tool = {
      name: "detox_init",
      description: "Initialize Detox in a React Native project. Creates e2e folder structure and configuration.",
      inputSchema: zodToJsonSchema(InitArgsSchema),
      handler: async (args: z.infer<typeof InitArgsSchema>) => {
        const parsed = InitArgsSchema.parse(args);
        const cliArgs: string[] = ["init"];
    
        if (parsed.testRunner) {
          cliArgs.push("-r", parsed.testRunner);
        }
    
        const result = await executeDetoxCommand(cliArgs, { cwd: parsed.projectPath });
    
        return {
          success: result.success,
          output: result.stdout,
          errors: result.stderr,
          message: result.success
            ? "Detox initialized successfully. Check the e2e folder for test files."
            : "Failed to initialize Detox.",
        };
      },
    };
  • Zod input schema for detox_init tool defining projectPath (required) and testRunner (optional, defaults to 'jest').
    export const InitArgsSchema = z.object({
      projectPath: z.string().describe("Path to React Native project root"),
      testRunner: z.enum(["jest", "mocha"]).optional().default("jest"),
    });
    
    export type InitArgs = z.infer<typeof InitArgsSchema>;
  • The detox_init tool (initTool) is registered by inclusion in the allTools export array used by the MCP server.
    initTool,
  • src/index.ts:40-48 (registration)
    MCP ListTools handler that registers all tools including detox_init by mapping from allTools.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: allTools.map((tool) => ({
          name: tool.name,
          description: tool.description,
          inputSchema: tool.inputSchema,
        })),
      };
    });
  • src/index.ts:50-94 (registration)
    MCP CallTool handler that dispatches to the specific tool handler (including detox_init) found by name in allTools.
    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?

With no annotations, the description carries full burden but only mentions creation actions without detailing behavioral traits like side effects (e.g., file system changes), permissions needed, error handling, or output format. It lacks critical context for a tool that modifies project structure.

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 two concise sentences that are front-loaded with the core purpose and efficiently detail the outcome (creates e2e folder structure and configuration). Every word adds value without redundancy.

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's complexity (initializing a testing framework with file system changes), lack of annotations, no output schema, and incomplete parameter documentation, the description is insufficient. It doesn't address what happens on success/failure, output details, or integration with sibling tools, leaving significant gaps.

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 50% (only projectPath has a description), and the description adds no parameter-specific information beyond implying initialization in a React Native project. It doesn't compensate for the undocumented testRunner parameter or provide additional meaning, so it meets the baseline for moderate schema coverage.

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 action ('Initialize Detox') and the target ('in a React Native project'), specifying it creates an e2e folder structure and configuration. It distinguishes from siblings like detox_build or detox_test by focusing on setup rather than execution or generation, though it doesn't explicitly name alternatives.

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 like detox_create_config or detox_generate_test. The description implies it's for initial setup but doesn't specify prerequisites, exclusions, or context for choosing among sibling tools.

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