HostRunner connects an LLM to your MCP tools, letting you test how models interact with your server. It handles the agentic loop (prompt → tool call → result → response) and gives you rich inspection capabilities.
Why Test with LLMs?
Unit tests verify your tools work correctly in isolation. But in production, an LLM decides which tool to call and what arguments to pass. Testing with real LLMs catches issues like:- Ambiguous tool descriptions that confuse the model
- Missing or unclear parameter documentation
- Tools that the model consistently misuses
- Edge cases in natural language interpretation
Creating a HostRunner
mcpClientManager instance when you use MCP App tools and upload evals to MCPJam: that enables getWidgetSnapshots() (HTML from readResource on ui.resourceUri) so traces can replay widgets offline. See the HostRunner reference.
Running Prompts
Send natural language prompts and inspect what happens:The PromptResult Object
Every prompt returns aPromptResult with rich inspection methods:
HostRunner never throws exceptions. Errors are captured in the result, making it safe to run many tests without try/catch blocks.Multi-Turn Conversations
Pass previous results as context to maintain conversation history:Tuning Agent Behavior
System Prompt
Guide the model’s behavior:Temperature
Control randomness (lower = more deterministic):Max Steps
Limit the agentic loop iterations:Control Multi-Step Loops with stopWhen
UsestopWhen when you want to stop the multi-step loop after a particular step completes:
Bound Prompt Runtime with timeout
Usetimeout when you want to bound how long HostRunner.run() can run:
Writing Assertions
Use validators to assert tool call behavior:Performance Insights
Understand where time is spent:Next Steps
Running Evals
Run statistical evaluations
HostRunner Reference
Full API documentation
PromptResult Reference
All result methods
Validators Reference
Assertion functions

