update_contam_project_references
Edit weather, contaminant, and library file references in CONTAM project files to update simulation inputs and configurations.
Instructions
Use this when you need to edit the referenced weather, contaminant, or library files inside a CONTAM .prj file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | ||
| weatherFile | No | ||
| contaminantFile | No | ||
| continuousValuesFile | No | ||
| discreteValuesFile | No | ||
| wpcFile | No | ||
| ewcFile | No | ||
| createBackup | No |
Implementation Reference
- contam-mcp/src/server.js:2223-2299 (handler)The tool "update_contam_project_references" implementation, which reads a project file, updates the file paths for external dependencies (weather, contaminant, etc.), and saves the updated project file.
"update_contam_project_references", "Use this when you need to edit the referenced weather, contaminant, or library files inside a CONTAM .prj file.", { projectPath: z.string(), weatherFile: z.string().nullable().optional(), contaminantFile: z.string().nullable().optional(), continuousValuesFile: z.string().nullable().optional(), discreteValuesFile: z.string().nullable().optional(), wpcFile: z.string().nullable().optional(), ewcFile: z.string().nullable().optional(), createBackup: z.boolean().optional() }, async ({ projectPath, weatherFile, contaminantFile, continuousValuesFile, discreteValuesFile, wpcFile, ewcFile, createBackup }) => { const resolvedProjectPath = asAbsolutePath(projectPath); if (!(await fileExists(resolvedProjectPath))) { throw new Error(`Project file not found: ${resolvedProjectPath}`); } const requestedUpdates = { weatherFile, contaminantFile, continuousValuesFile, discreteValuesFile, wpcFile, ewcFile }; const keysToUpdate = Object.keys(requestedUpdates).filter( (key) => Object.prototype.hasOwnProperty.call(requestedUpdates, key) && requestedUpdates[key] !== undefined ); if (keysToUpdate.length === 0) { throw new Error("No reference updates were provided."); } const lines = await readProjectLines(resolvedProjectPath); const inspectionBefore = inspectContamProjectLines(lines); for (const key of keysToUpdate) { const descriptor = projectReferenceDescriptors.find((item) => item.key === key); const reference = inspectionBefore.references[key]; if (!descriptor || !reference || reference.lineNumber === null) { throw new Error(`Could not find a '${key}' line inside ${resolvedProjectPath}.`); } const lineIndex = reference.lineNumber - 1; lines[lineIndex] = buildReferenceLine(lines[lineIndex], reference.comment, requestedUpdates[key]); } if (createBackup !== false) { const backupPath = `${resolvedProjectPath}.mcp.bak`; if (!(await fileExists(backupPath))) { await copyFile(resolvedProjectPath, backupPath); } } await writeFile(resolvedProjectPath, `${lines.join("\r\n")}\r\n`, { encoding: "utf8" }); const inspectionAfter = await inspectContamProject(resolvedProjectPath); return toolResponse("Updated CONTAM project references.", { projectPath: resolvedProjectPath, backupCreated: createBackup !== false, requestedUpdates, before: inspectionBefore.references, after: inspectionAfter.references }); } );