Compile & Diagnose Solidity
evm_compile_and_diagnoseCompile a Foundry project and return structured compiler diagnostics. On failure, provides file, line, column, message, and code snippet for each error.
Instructions
Run forge build and return structured compiler diagnostics.
If compilation succeeds, returns { "success": true, "diagnostics": [] }. If compilation fails, parses the error output into a JSON array of diagnostics.
Args:
projectPath (string): Absolute path to the Foundry project
Returns: { "success": boolean, // true if the project compiled cleanly "diagnostics": [ { "file": string, // e.g. "src/Token.sol" "line": number, // Line number (1-indexed) "column": number, // Column number (1-indexed) "message": string, // Compiler error message "snippet": string // Code snippet around the error } ] }
Examples:
"Check if my contracts compile" → projectPath = "/path/to/project"
"Fix the compilation error" → call this tool, read the diagnostics, fix the file
Error Handling:
Returns isError=true if forge is not installed
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Absolute path to the Foundry project root |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | ||
| diagnostics | Yes |