export_contam_sim_text
Run CONTAM simulations automatically by providing pre-defined responses to interactive prompts, enabling batch processing of airflow and contaminant transport models.
Instructions
Use this when you need to run simread on a .sim file and you already know the response-script text needed for the interactive prompts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| simPath | Yes | ||
| responsesText | No | ||
| responsesFilePath | No | ||
| timeoutSeconds | No |
Implementation Reference
- contam-mcp/src/server.js:2901-2947 (handler)The tool `export_contam_sim_text` is defined and implemented here as an MCP tool using the `simread` executable. It handles the interactive nature of `simread` by accepting response text or a file path to feed via stdin.
server.tool( "export_contam_sim_text", "Use this when you need to run simread on a .sim file and you already know the response-script text needed for the interactive prompts.", { simPath: z.string(), responsesText: z.string().optional(), responsesFilePath: z.string().optional(), timeoutSeconds: z.number().int().min(1).max(3600).optional() }, async ({ simPath, responsesText, responsesFilePath, timeoutSeconds }) => { if (!responsesText && !responsesFilePath) { throw new Error("Provide either responsesText or responsesFilePath. simread is interactive, so MCP usage must supply a response script."); } const executablePath = await resolveExecutable("simread"); const resolvedSimPath = asAbsolutePath(simPath); if (!(await fileExists(resolvedSimPath))) { throw new Error(`SIM file not found: ${resolvedSimPath}`); } const resolvedResponsesFilePath = responsesFilePath ? asAbsolutePath(responsesFilePath) : null; const inputText = responsesText ?? normalizeText(await readFile(resolvedResponsesFilePath, { encoding: "utf8" })).concat("\n"); const simDirectory = path.dirname(resolvedSimPath); const before = await snapshotDirectory(simDirectory); const result = await runProcess(executablePath, [resolvedSimPath], { cwd: simDirectory, timeoutSeconds: timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS, stdinText: inputText.endsWith("\n") ? inputText : `${inputText}\n` }); const after = await snapshotDirectory(simDirectory); return toolResponse( result.ok ? "simread completed successfully." : "simread finished with errors or a non-zero exit code.", { executablePath, simPath: resolvedSimPath, responsesSource: resolvedResponsesFilePath ?? "inline responsesText", ...result, fileChanges: diffSnapshots(before, after) } ); } );