Skip to main content
The 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

TestFunction Type

The test function receives a HostExecutor (the interface implemented by both HostRunner and HostRuntime) and must return a boolean:
  • true = test passed
  • false = test failed
Both 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.

Returns

number - True positives / (True positives + False positives).

recall()

Returns the recall metric.

Returns

number - True positives / (True positives + False negatives).

truePositiveRate()

Returns the true positive rate (same as recall).

falsePositiveRate()

Returns the false positive rate.

Returns

number - False positives / (False positives + True negatives).

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 (via getName()).

Test Function Patterns

Simple Tool Check

Argument Validation

Response Content

Multiple Conditions

Multi-Turn Conversation

With Validators


Complete Example