diagnose_contam_project
Inspect referenced support files and identify nearby candidate matches when a CONTAM project fails to run, enabling airflow and contaminant transport modeling diagnostics.
Instructions
Use this when a CONTAM project fails to run and you want to inspect referenced support files and nearby candidate matches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | ||
| workingDirectory | No | ||
| searchRecursively | No | ||
| maxMatchesPerReference | No |
Implementation Reference
- contam-mcp/src/server.js:2140-2220 (handler)Handler implementation for the diagnose_contam_project MCP tool.
server.tool( "diagnose_contam_project", "Use this when a CONTAM project fails to run and you want to inspect referenced support files and nearby candidate matches.", { projectPath: z.string(), workingDirectory: z.string().optional(), searchRecursively: z.boolean().optional(), maxMatchesPerReference: z.number().int().min(1).max(20).optional() }, async ({ projectPath, workingDirectory, searchRecursively, maxMatchesPerReference }) => { const resolvedProjectPath = asAbsolutePath(projectPath); if (!(await fileExists(resolvedProjectPath))) { throw new Error(`Project file not found: ${resolvedProjectPath}`); } const inspection = await inspectContamProject(resolvedProjectPath); const projectDirectory = path.dirname(resolvedProjectPath); const resolvedWorkingDirectory = asAbsolutePath(workingDirectory ?? projectDirectory); const recursiveSearch = searchRecursively ?? true; const referenceDiagnostics = {}; for (const descriptor of projectReferenceDescriptors) { const reference = inspection.references[descriptor.key]; if (!reference || reference.value === null) { referenceDiagnostics[descriptor.key] = { label: descriptor.commentLabel, status: "unset", configuredValue: null, directMatches: [], nearbyMatches: [], suggestedValue: null }; continue; } const directCandidates = unique([ asAbsolutePath(reference.value, resolvedWorkingDirectory), asAbsolutePath(reference.value, projectDirectory) ]); const directMatches = []; for (const candidate of directCandidates) { if (await fileExists(candidate)) { directMatches.push(candidate); } } const nearbyMatches = recursiveSearch && directMatches.length === 0 ? await findFilesByBasename( projectDirectory, path.basename(reference.value), maxMatchesPerReference ?? 5 ) : []; const bestMatch = directMatches[0] ?? nearbyMatches[0] ?? null; const suggestedValue = bestMatch ? path.relative(projectDirectory, bestMatch) || path.basename(bestMatch) : null; referenceDiagnostics[descriptor.key] = { label: descriptor.commentLabel, status: directMatches.length > 0 ? "resolved" : nearbyMatches.length > 0 ? "found-nearby" : "missing", configuredValue: reference.value, directMatches, nearbyMatches, suggestedValue }; } return toolResponse("Diagnosed CONTAM project dependencies.", { projectPath: resolvedProjectPath, workingDirectory: resolvedWorkingDirectory, recursiveSearch, inspection, references: referenceDiagnostics }); } );