Analyze EVM Gas Profile
evm_analyze_gas_profileRun forge test --gas-report on a Foundry project and return structured gas consumption data per contract and function, including deployment cost, bytecode size, and function gas metrics.
Instructions
Run forge test --gas-report and return structured gas consumption data per contract and function.
Args:
projectPath (string): Absolute path to a Foundry project (must contain foundry.toml)
Returns: JSON object: { "contracts": [ { "name": string, // e.g. "src/Token.sol:Token" "deploymentCost": number, // Gas used for deployment "deploymentSize": number, // Bytecode size in bytes "functions": [ { "name": string, // Function name "min": number, // Minimum gas "avg": number, // Average gas "median": number, // Median gas "max": number, // Maximum gas "calls": number // Number of calls in tests } ] } ] }
Examples:
"Show gas usage for my project" → projectPath = "/path/to/foundry-project"
Do NOT use for security auditing (use evm_scan_vulnerabilities instead)
Error Handling:
Returns isError=true if Foundry is not installed or tests fail to compile
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Absolute path to the Foundry project root |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contracts | Yes |