forge-test-mcp
v0.1.0Runs Foundry tests and builds; returns compact, structured failures to AI coding agents
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
run_tests
Run `forge test` and return a compact summary: counts, and for each failing test its kind (unit, fuzz, invariant, setup), decoded reason, fuzz counterexample or invariant call sequence, and console logs. isError means the tests did not run (compile error, no matching tests, timeout, missing forge, …); never report that as passing.
| Parameter | Type | Description |
|---|---|---|
fuzz_runs | integer | Override fuzz runs. A value below the project setting is reported as reduced; do not use it to make tests pass. |
match_contract | string | Only run test contracts matching this regex. |
match_path | string | Only run test files matching this glob. |
match_test | string | Only run test functions matching this regex. |
max_bytes | integer | Response size budget in bytes (default 8192). |
traces | boolean | Attach a decoded trace excerpt to the first 5 failures (a second, text-mode forge run). Default true. |
explain_failure
Re-run one test at high verbosity and return only that test: its reason, decoded call trace (trimmed to the path to the revert when long), backtrace, logs and, for fuzz or invariant tests, the counterexample. Pass the test name as run_tests reports it, e.g. "BankTest.test_transfer()".
| Parameter | Type | Description |
|---|---|---|
test * | string | Test function, optionally with its contract: "Contract.test_name()". |
contract | string | Test contract, if not given in `test`. |
max_bytes | integer | Response size budget in bytes (default 8192). |
build
Compile the project with `forge build` and return compiler errors and warnings as structured items (file, line, column, code, message). Unchanged files are not recompiled and forge does not repeat their warnings; pass force: true to recompile everything.
| Parameter | Type | Description |
|---|---|---|
force | boolean | Recompile everything, so warnings for unchanged files are reported again. |
max_bytes | integer | Response size budget in bytes (default 8192). |