detox_read_config
Read and parse the Detox mobile testing configuration file to access test settings and parameters for React Native E2E testing.
Instructions
Read and parse the current Detox configuration file (.detoxrc.js or similar).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | No | Path to project root | |
| configPath | No | Explicit path to config file |
Implementation Reference
- src/tools/index.ts:179-202 (handler)The primary handler implementation for the 'detox_read_config' tool, which parses input arguments and calls readDetoxConfig to retrieve and return the Detox configuration.export const readConfigTool: Tool = { name: "detox_read_config", description: "Read and parse the current Detox configuration file (.detoxrc.js or similar).", inputSchema: zodToJsonSchema(ReadConfigArgsSchema), handler: async (args: z.infer<typeof ReadConfigArgsSchema>) => { const parsed = ReadConfigArgsSchema.parse(args); const projectPath = parsed.projectPath || process.cwd(); const result = await readDetoxConfig(projectPath); if (!result) { return { success: false, error: "No Detox configuration found. Run 'detox init' to create one.", }; } return { success: true, configPath: result.configPath, config: result.config, }; }, };
- src/utils/validators.ts:46-51 (schema)Zod schema defining the input parameters for the detox_read_config tool, used for validation and JSON schema generation.export const ReadConfigArgsSchema = z.object({ projectPath: z.string().optional().describe("Path to project root"), configPath: z.string().optional().describe("Explicit path to config file"), }); export type ReadConfigArgs = z.infer<typeof ReadConfigArgsSchema>;
- src/utils/config-parser.ts:105-120 (helper)Core helper function that locates the Detox config file, parses it, and returns the configuration object or null if not found.export async function readDetoxConfig(projectPath: string): Promise<{ config: DetoxConfig; configPath: string; } | null> { const configPath = await findConfigFile(projectPath); if (!configPath) { return null; } try { const config = await parseConfig(configPath); return { config, configPath }; } catch (error) { throw new Error(`Failed to parse Detox config at ${configPath}: ${error}`); } }
- src/tools/index.ts:429-442 (registration)Registration of all MCP tools including 'detox_read_config' (as readConfigTool) in the allTools export array.export const allTools: Tool[] = [ buildTool, testTool, initTool, readConfigTool, listConfigurationsTool, validateConfigTool, createConfigTool, listDevicesTool, generateTestTool, generateMatcherTool, generateActionTool, generateExpectationTool, ];