EvalTest class runs a single test scenario multiple times and provides statistical metrics like accuracy, precision, and recall.
Import
Constructor
Parameters
EvalTestConfig
required
Configuration for the evaluation test.
EvalTestConfig
matchOptions
Layered suite → case, and validated when the test is constructed rather than mid-run.predicates
Deterministic, state-based checks evaluated against the iteration transcript — same transcript, same verdict, which is what makes them usable as a CI gate. An iteration passes only if every predicate passes, independently offailOnToolError. Verdicts are reported under metadata.predicates, so the dashboard’s check chips work for code-first runs too. See eval reporting for the full list of predicate types.
widgetRendered, widgetRenderLatencyUnder, widgetNoConsoleErrors) need render observations only a hosted run captures, so EvalTest rejects them at construction instead of failing every iteration.
TestFunction Type
HostExecutor (the interface implemented by both HostRunner and HostRuntime) and must return a boolean:
true= test passedfalse= test failed
HostRunner, HostRuntime, and mock executors implement the HostExecutor interface, so you can use any of them for testing.
Example
Methods
run()
Executes the test multiple times and returns detailed results.Parameters
EvalTestRunOptions
Results are automatically saved to MCPJam after the run completes when an API
key is available via
mcpjam.apiKey or the MCPJAM_API_KEY environment
variable. Set mcpjam.enabled: false to disable.ProgressCallback Type
Example
accuracy()
Returns the success rate (0.0 - 1.0).Returns
number - Proportion of tests that passed.
Example
precision()
Returns the precision metric, micro-averaged over the run’s tool-call matches.Returns
number — True positives / (True positives + False positives).
Counted per iteration from the expected/actual tool calls: a matched expectation is a true positive, an unexpected call is a false positive, a missing one is a false negative, and an argument mismatch counts as both.
recall()
Returns the recall metric, micro-averaged over the run’s tool-call matches.Returns
number — True positives / (True positives + False negatives).
Throws when the run declared no expectedToolCalls.
truePositiveRate()
Returns the true positive rate (same as recall).unexpectedToolCallRate()
The fraction of expectation-bearing iterations that made at least one tool call nobody asked for.Returns
number — Iterations with an extra call / iterations that had expectations. 0 when the run declared no expectations.
falsePositiveRate()
averageTokenUse()
Returns the average tokens used per iteration.Returns
number - Mean token count.
Example
getResults()
Returns the full run result from the last run.Returns
EvalRunResult | null - The run result, or null if run() hasn’t been called.
EvalRunResult Type
IterationResult Type
getName()
Returns the test’s name.getConfig()
Returns the test’s configuration.getAllIterations()
Returns all iteration details from the last run.getFailedIterations()
Returns only the failed iterations from the last run.Example
getSuccessfulIterations()
Returns only the successful iterations from the last run.getFailureReport()
Returns a formatted failure report with traces from all failed iterations. Useful for debugging.Example
Properties
name
The test’s identifier (viagetName()).
Test Function Patterns
Simple Tool Check
Argument Validation
Response Content
Multiple Conditions
Multi-Turn Conversation
With Validators
Complete Example
Related
- Running Evals - Conceptual guide
- EvalSuite Reference - Group multiple tests
- Saving Eval Results - Save results to MCPJam
- Validators Reference - Assertion functions

