Skip to main content

Overview

generate_test_suite is an MCP tool that scaffolds a complete test suite — both the YAML manifest and the Python implementation file — from a description. When signal context is available (from a DBC or rig TOML) and an AI key is present, the Python stubs contain real assertions rather than pass placeholders. This is exposed as:
  • An MCP tool callable from Claude, Copilot, or Cursor
  • A function in crucihil.mcp.tools.suites for programmatic use

How it works

Context sources

The tool builds context from up to three sources, merged in priority order: When all three are provided, the AI has a complete picture of the hardware and can generate test functions that reference real signal names.

AI generation

When context is available and an AI key is detected:
  1. A prompt is built: suite name, description, rig name, and all context items
  2. The AI generates async Python test functions using the rig.can.expect/rig.can.send API
  3. Function names are extracted from the AI output and used to populate the YAML manifest
When no AI key is present, a static placeholder stub is written instead.

Output files

The tool writes two files:
  • <output_dir>/<suite_name>.yaml — YAML v2 manifest with test IDs, tags, and module paths
  • <output_dir>/<suite_name>.py — Python file with typed async test functions

Using from an AI assistant

With the MCP server connected to Claude Desktop, Copilot, or Cursor:
The tool call:

Example generated YAML

Example generated Python

Parameters

string
required
Snake-case name for the suite (e.g. brake_validation). Used as the filename and YAML suite.name.
string
required
One-sentence description of what the suite validates. Included in the YAML and the Python file header.
string
default:"Virtual_Sim"
Hardware variant to target. Written to defaults.hw_variants in the YAML.
string
default:"tests/suites"
Directory to write both files. Created if it does not exist.
list[string]
Manual context items merged on top of auto-extracted DBC/TOML context. Can contain anything: signal names, fault scenarios, integration flows, sensor feeds, or plain descriptions. Examples: ["can_dropout on EngineData", "ECU startup sequence", "verify camera latency under 50ms"].
string
Path to a rig TOML. Auto-extracts ECU names, power rail names, and GPIO availability. Interface names and IPs are never extracted (hardware details stay in TOML).
string
Path to a DBC file. Auto-extracts every MessageName.SignalName pair with exact DBC names — no hallucination.
string
AI provider override: anthropic, openai, or gemini. Auto-detected from env vars if not set.

Return value

After generation

The generated files work immediately with crucihil run:
Edit the Python file to sharpen assertions, add signal tolerance checks, or wire up fault injection scenarios. Then run against real hardware by swapping the rig TOML — the Python file stays the same.

See also