Skip to main content

mcp_trace_validator/
lib.rs

1// SPDX-License-Identifier: MIT
2// Copyright 2026 Tom F. (https://github.com/tomtom215)
3
4//! Deterministic offline validation of recorded MCP protocol traces.
5//!
6//! The validator replays a trace (JSON Lines of
7//! [`mcp_conformance_core::trace::TraceEvent`]) against a requirement registry and
8//! produces a [`report::Report`] with one outcome per requirement and a precise
9//! [`report::Finding`] for every violation: requirement ID, offending event `seq`, and
10//! an actionable detail string.
11//!
12//! Three properties are load-bearing and tested, not aspirational:
13//!
14//! 1. **Determinism** — same trace bytes, same registry: byte-identical report. The
15//!    engine touches no clock, no randomness, no environment.
16//! 2. **No I/O in the engine** — [`engine::validate`] is a pure function over parsed
17//!    events; reading files and rendering output happen at the CLI edge.
18//! 3. **Honest accounting** — requirements the registry excludes are reported as
19//!    excluded (never as passed), and registry entries referencing checks this build
20//!    does not implement are reported as unsupported (never silently skipped).
21//!
22//! # Example
23//!
24//! ```
25//! use mcp_conformance_core::requirement::Registry;
26//! use mcp_trace_validator::{engine, reader};
27//!
28//! let trace = r#"{"seq":0,"direction":"client-to-server","transport":"stdio","kind":"message","payload":{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"x","version":"0"}}}}
29//! {"seq":1,"direction":"server-to-client","transport":"stdio","kind":"message","payload":{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-11-25","capabilities":{},"serverInfo":{"name":"y","version":"0"}}}}
30//! {"seq":2,"direction":"client-to-server","transport":"stdio","kind":"message","payload":{"jsonrpc":"2.0","method":"notifications/initialized"}}
31//! "#;
32//!
33//! let registry = Registry::builtin_2025_11_25().expect("embedded registry is valid");
34//! let events = reader::parse_trace(trace, &reader::Limits::default()).expect("valid trace");
35//! let report = engine::validate(&registry, &events);
36//! assert!(!report.has_errors(), "{report:#?}");
37//! ```
38
39pub mod checks;
40pub mod context;
41pub mod engine;
42pub mod junit;
43pub mod multi;
44pub mod reader;
45pub mod report;