Skip to main content
Learn proven patterns for testing MCP servers and agents. Each workflow includes practical examples and tips from real-world usage.

Write your first test

1

Choose a test style

Pick the style that fits your workflow:Decorator (simplest):
Pytest (familiar):
2

Add meaningful assertions

Start simple, then add more specific checks:
3

Run and iterate

Review failures, adjust assertions, and rerun.
Start with simple content assertions, then gradually add tool and performance checks as you understand your system’s behavior.

Test an MCP server comprehensively

1

Identify server capabilities

List all tools your server provides:
Note the available tools and their expected behaviors.
2

Create test scenarios for each tool

Write tests covering normal and edge cases:
3

Test error handling

Verify graceful failure:
4

Create a comprehensive dataset

For systematic testing:

Create and enforce a golden path

Ensure your agent follows the optimal execution path:
1

Define the ideal tool sequence

Identify the minimal, correct sequence of tools:
2

Add path efficiency assertion

3

Debug path violations

When tests fail, examine the actual path:
4

Refine agent instructions

If the agent deviates, improve its instructions:
Golden paths work best for deterministic workflows. For creative tasks, consider using allow_extra_steps or checking only critical waypoints.

Build quality gates with LLM judges

1

Start with a simple rubric

Define what “good” looks like:
2

Combine with structural checks

Don’t rely solely on judges:
3

Use multi-criteria for complex evaluation

4

Calibrate thresholds

Run tests, collect scores, adjust:
Pro tip: Use Anthropic Claude (Opus or Sonnet) for best judge quality. They provide more consistent and nuanced evaluations.

Integrate with CI/CD

1

Add GitHub Actions workflow

Create .github/workflows/mcp-eval.yml using the reusable workflow:
This reusable workflow automatically:
  • Runs tests and generates reports
  • Posts PR comments with results
  • Uploads artifacts
  • Deploys badges and HTML reports to GitHub Pages (on main branch)
2

Enable GitHub Pages

In your repository settings:
  1. Go to Settings → Pages
  2. Source: Deploy from a branch
  3. Branch: gh-pages (created automatically by the workflow)
  4. Save the settings
Your badges and reports will be available at:
  • Badges: https://YOUR_USERNAME.github.io/YOUR_REPO/badges/
  • Report: https://YOUR_USERNAME.github.io/YOUR_REPO/
3

Add test badges from GitHub Pages

After deploying to GitHub Pages, you may add badges to your README.md to show users your mcp-eval test and coverage status:
These badges will automatically update after each push to main.
4

Configure failure conditions

Make tests fail the build appropriately:

Generate tests with AI

1

Use the generate command

Let AI create test scenarios:
2

Review and customize

AI-generated tests are a starting point:
3

Update existing tests

Add new scenarios to existing files:

Debug failing tests

1

Enable verbose output

Shows tool calls, responses, and assertion details.
2

Examine OTEL traces

Look in test-reports/test_name_*/trace.jsonl:
3

Use doctor and validate commands

4

Add debug assertions

Next steps

Master these advanced topics:

Dataset Testing

Systematic evaluation at scale

Custom Evaluators

Build domain-specific checks

Performance Tuning

Optimize test execution