evaluateToolCalls — a richer, configurable matcher that returns structured results.
Import
Tool Name Validators
matchToolCalls()
Exact match - all tools in exact order.Parameters
| Parameter | Type | Description |
|---|---|---|
expected | string[] | Expected tool names in order |
actual | string[] | Actual tool names (from result.toolsCalled()) |
Returns
boolean - true if exact match.
Example
matchToolCallsSubset()
Checks if all expected tools were called (any order, extras allowed).Parameters
| Parameter | Type | Description |
|---|---|---|
expected | string[] | Tools that must be present |
actual | string[] | Actual tool names |
Returns
boolean - true if all expected tools are present.
Example
matchAnyToolCall()
Checks if at least one expected tool was called.Parameters
| Parameter | Type | Description |
|---|---|---|
expected | string[] | Any of these tools should be called |
actual | string[] | Actual tool names |
Returns
boolean - true if at least one match.
Example
matchToolCallCount()
Checks if a tool was called exactly N times.Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | Tool to count |
actual | string[] | Actual tool names |
count | number | Expected count |
Returns
boolean - true if count matches.
Example
matchNoToolCalls()
Checks that no tools were called.Parameters
| Parameter | Type | Description |
|---|---|---|
actual | string[] | Actual tool names |
Returns
boolean - true if empty.
Example
Argument Validators
matchToolCallWithArgs()
Checks if a tool was called with exactly the specified arguments.Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | Tool to check |
expectedArgs | Record<string, unknown> | Expected arguments (exact match) |
toolCalls | ToolCall[] | From result.getToolCalls() |
Returns
boolean - true if exact argument match.
Example
matchToolCallWithPartialArgs()
Checks if a tool was called with arguments containing the expected subset.Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | Tool to check |
expectedArgs | Record<string, unknown> | Arguments to match (subset) |
toolCalls | ToolCall[] | From result.getToolCalls() |
Returns
boolean - true if all expected args present with matching values.
Example
matchToolArgument()
Checks if a specific argument has the expected value.Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | Tool to check |
argName | string | Argument name |
expectedValue | unknown | Expected value |
toolCalls | ToolCall[] | From result.getToolCalls() |
Returns
boolean - true if argument matches.
Example
matchToolArgumentWith()
Checks if an argument passes a custom predicate.Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | Tool to check |
argName | string | Argument name |
predicate | (value: unknown) => boolean | Custom validation function |
toolCalls | ToolCall[] | From result.getToolCalls() |
Returns
boolean - true if predicate returns true.
Example
Usage with Test Frameworks
Jest / Vitest
With EvalTest
evaluateToolCalls()
A configurable matcher that returns a structured result instead of a plain boolean. Use this when you need to know why a match failed (missing tools, argument mismatches, wrong order, extra calls) or when you want to control matching behavior per test case.Parameters
| Parameter | Type | Description |
|---|---|---|
expected | EvalToolCall[] | Expected tool calls (each has toolName and optional arguments) |
actual | EvalToolCall[] | Actual tool calls from the trace |
options | EvalMatchOptions | Matching behavior overrides (see below) |
EvalMatchOptions
| Option | Type | Default | Description |
|---|---|---|---|
toolCallOrder | "ignore" | "strict" | "ignore" | "strict" requires matched calls to appear in the same relative order as expected. |
allowExtraToolCalls | boolean | true | When false, any actual call beyond what’s expected fails the test. |
argumentMatching | "partial" | "exact" | "ignore" | "partial" | "partial" checks only expected keys and supports type placeholders ("string", "number", "any", etc.). "exact" requires deep equality. "ignore" skips argument comparison. |
EvalToolCallMatchResult
| Property | Type | Description |
|---|---|---|
passed | boolean | Whether the match succeeded. |
missing | EvalToolCall[] | Expected calls that were not found in actual. |
extra | EvalToolCall[] | Actual calls beyond what was expected. |
outOfOrder | EvalOutOfOrderToolCall[] | Matched calls that appeared in the wrong order (only populated when toolCallOrder: "strict"). |
argumentMismatches | EvalArgumentMismatch[] | Calls matched by name but with incompatible arguments. |
Example
Argument type placeholders
WhenargumentMatching is "partial" (the default), string values in expected arguments are interpreted as type checks:
| Placeholder | Matches |
|---|---|
"any" | Any non-undefined value |
"string" | typeof value === "string" |
"number" | typeof value === "number" |
"boolean" | typeof value === "boolean" |
"object" | Non-null, non-array object |
"array" | Array |
"null" | null |
Layered match options
resolveMatchOptions merges suite → case → run-override layers on top of defaults. Import it from @mcpjam/sdk/matchers when building custom eval pipelines:
Quick Reference
| Validator | Use Case |
|---|---|
evaluateToolCalls | Structured match with detailed diagnostics |
matchToolCalls | Exact sequence of tools |
matchToolCallsSubset | Required tools (any order) |
matchAnyToolCall | At least one of these tools |
matchToolCallCount | Tool called N times |
matchNoToolCalls | No tools called |
matchToolCallWithArgs | Exact argument match |
matchToolCallWithPartialArgs | Subset of arguments |
matchToolArgument | Single argument value |
matchToolArgumentWith | Custom validation |
Related
- Testing with LLMs - Conceptual guide
- PromptResult Reference - Get tool calls
- EvalTest Reference - Use in evaluations
- Saving Eval Results - Per-result
matchOptionsonEvalResultInput

