onetech_extract_module
Extract domain models, pages, microflows, and enumerations from Mendix modules using mx.exe. Generates comprehensive JSON documentation of complete module structure for local analysis.
Instructions
Extract domain model, pages, microflows, and enumerations from a Mendix module using mx.exe. Returns JSON files with complete module structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| moduleName | Yes | Name of the module to extract (e.g., RequestHub) | |
| mprPath | Yes | Absolute path to the .mpr file (e.g., D:\Projects\OneTech.mpr) | |
| mxPath | No | Optional: Path to mx.exe (default: D:\Program Files\Mendix\11.3.0.80734\modeler\mx.exe) | |
| outputPath | Yes | Absolute path to output directory for JSON files |
Implementation Reference
- src/index.ts:92-178 (handler)Core handler function that performs the module extraction. Validates inputs, runs mx.exe dump-mpr commands for DomainModel, Pages, Microflows, and Enumerations, generates JSON files, and returns success status with file list.async function extractModule( mprPath: string, moduleName: string, outputPath: string, mxPath: string = DEFAULT_MX_PATH ): Promise<{ success: boolean; files: Array<{ name: string; size: number }>; message: string; }> { // Validate inputs await validateMxExe(mxPath); await validateMprFile(mprPath); await ensureOutputDir(outputPath); const files: Array<{ name: string; size: number }> = []; const errors: string[] = []; // Define the 4 mx.exe commands to extract module data const commands = [ { name: "DomainModel", unitType: "DomainModels$DomainModel", outputFile: join(outputPath, `${moduleName}-DomainModel.json`), }, { name: "Pages", unitType: "Pages$Page", outputFile: join(outputPath, `${moduleName}-Pages.json`), }, { name: "Microflows", unitType: "Microflows$Microflow", outputFile: join(outputPath, `${moduleName}-Microflows.json`), }, { name: "Enumerations", unitType: "Enumerations$Enumeration", outputFile: join(outputPath, `${moduleName}-Enumerations.json`), }, ]; // Execute each command sequentially for (const cmd of commands) { try { const args = ["dump-mpr", "--unit-type", cmd.unitType, "--module-names", moduleName, "--output-file", cmd.outputFile, mprPath]; await runMxCommand(mxPath, args); // Verify file was created and get size let fileContent = await readFile(cmd.outputFile, "utf-8"); // Remove UTF-8 BOM if present (mx.exe outputs BOM) if (fileContent.charCodeAt(0) === 0xfeff) { fileContent = fileContent.substring(1); } files.push({ name: `${cmd.name}.json`, size: Buffer.byteLength(fileContent, "utf-8"), }); } catch (error: any) { errors.push(`${cmd.name}: ${error.message}`); } } // Return results if (files.length === 0) { return { success: false, files: [], message: `Failed to extract module. Errors: ${errors.join(", ")}`, }; } if (errors.length > 0) { return { success: true, files, message: `Extracted ${files.length}/4 files successfully. Partial errors: ${errors.join(", ")}`, }; } return { success: true, files, message: `Successfully extracted ${files.length} files from module '${moduleName}'`, }; }
- src/index.ts:205-226 (schema)Input schema defining parameters for the onetech_extract_module tool: mprPath (required), moduleName (required), outputPath (required), mxPath (optional).inputSchema: { type: "object", properties: { mprPath: { type: "string", description: "Absolute path to the .mpr file (e.g., D:\\Projects\\OneTech.mpr)", }, moduleName: { type: "string", description: "Name of the module to extract (e.g., RequestHub)", }, outputPath: { type: "string", description: "Absolute path to output directory for JSON files", }, mxPath: { type: "string", description: `Optional: Path to mx.exe (default: ${DEFAULT_MX_PATH})`, }, }, required: ["mprPath", "moduleName", "outputPath"], },
- src/index.ts:199-230 (registration)Registration of the tool via the ListToolsRequestSchema handler, providing the tool name, description, and input schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "onetech_extract_module", description: "Extract domain model, pages, microflows, and enumerations from a Mendix module using mx.exe. Returns JSON files with complete module structure.", inputSchema: { type: "object", properties: { mprPath: { type: "string", description: "Absolute path to the .mpr file (e.g., D:\\Projects\\OneTech.mpr)", }, moduleName: { type: "string", description: "Name of the module to extract (e.g., RequestHub)", }, outputPath: { type: "string", description: "Absolute path to output directory for JSON files", }, mxPath: { type: "string", description: `Optional: Path to mx.exe (default: ${DEFAULT_MX_PATH})`, }, }, required: ["mprPath", "moduleName", "outputPath"], }, }, ], }; });
- src/index.ts:236-274 (handler)Dispatch handler in CallToolRequestSchema that invokes the extractModule function for the specific tool name and handles response/error formatting.if (request.params.name === "onetech_extract_module") { const { mprPath, moduleName, outputPath, mxPath } = request.params.arguments as { mprPath: string; moduleName: string; outputPath: string; mxPath?: string; }; try { const result = await extractModule(mprPath, moduleName, outputPath, mxPath || DEFAULT_MX_PATH); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify( { success: false, files: [], message: `Error: ${error.message}`, }, null, 2 ), }, ], isError: true, }; } }