---
name: creating-mcp-agent-evals
description: Use when writing Langfuse evals for an MCP tool family, or diagnosing failing eval cases to decide if the case, tool, or description is at fault.
---
# Creating MCP agent evals
## What this does
Builds a small, calibrated Langfuse eval suite for one MCP tool family, then uses its failures to fix the tools. Core principle: **evals are designed from user intent, never from tool descriptions**. Descriptions get fixed afterward so naive agents pass.
## When to use
- Adding evals for a tool family (tasks, storage, runs, ...).
- Eval cases fail and you must decide whether the case, the tool or its description is at fault.
- Eval runs show tool errors in Langfuse traces.
## How to run it
1. **Inventory the tools.** Every tool and argument group needs at least one case.
2. **Probe the platform first.** Verify API behavior (required fields, uniqueness, limits, errors) with a throwaway script against the real API before writing any case that depends on it.
3. **Two datasets, one per CI gate.** `mcp-server-evals-pr` holds `kind: "tool-call"` items (single-turn, only the first tool call asserted, no judge). `mcp-server-evals-merge` holds `kind: "agent"` items (multi-turn, scored by an LLM judge). Tool-call cases set `expectedTools` and optionally `expectedArgs` (flat object; listed keys must deep-equal). Agent cases that provoke an error on purpose set `metadata.expectedErrors` to the tool names allowed to fail. Item ids: `pr/<tool>/<slug>` or `merge/<family>/<slug>`.
4. **Write cases in waves:** 2-3 easy, 1-2 medium (chains), 2-3 hard (vague language, error recovery, collisions). Run and review each wave before the next.
5. **Calibrate on the strongest model first.** A failure there is a case defect or product gap, not a description problem.
6. **Ladder down** (Sonnet, then Haiku). Pass on strong and fail on weak means the description or output doesn't carry a naive agent.
7. **Fix tools via outputs before descriptions.** A steering sentence in the tool response reaches every agent on every call.
Diagnose a failed case in this order (read the transcript first; the judge's one-liner is only a hint):
- **Case:** query needs context the agent can't get, or input violates the schema. Rewrite self-contained.
- **Judge/reference:** reference demands what the judge can't observe. Reword `expectedOutput`.
- **Product:** tool can't satisfy a natural request. Surface as a decision.
- **Description/output:** model stalls, guesses, or misreads a field. Output nudge first, then description.
- **World:** live target is down or empty. Use stable hosts; make references outage-tolerant.
- **Model:** policy-shaped refusal or stubborn habit. Scope the deliverable down, or document the residual and stop tuning.
Rules:
- References are judge-checkable contracts: "PASS only if `<tool>` was called with `<arg>` and the final answer states `<fact>`. FAIL if ...".
- Write queries in user language; hard cases never name a tool.
- Never downgrade span levels to hide errors; use `metadata.expectedErrors`. The gate is zero tool errors on MCP calls except named ones.
- The judge never sees tool results; write references that pre-empt misreadings.
- Fail false claims, not etiquette.
- Tool-call cases must accept every defensible tool: list both in `expectedTools`.
- Probe live-web targets at authoring time.
- State is account-global: use `eval-` prefixes and `{{uniq}}` in every created name, in the query and the reference. Make each conversation self-contained.
- Dataset item ids are project-unique forever.
Red flags: writing a case while reading the tool description; an error-provoking agent case with no `expectedErrors`; a rerun that "fixed" an undiagnosed failure; editing a tool after one model failed once; fake URLs like `example.com` in queries; demanding long verbatim reproduction; `maxTurns` too low for chain cases.
## Output
- Eval dataset items for the tool family, plus a coverage matrix showing every tool and argument group is covered.
- Per-model pass results and, for each failure, a diagnosis (case, judge, product, description, world or model) with the fix applied.
## Credit
Based on public content by apify, packaged by Orbit.