Crate mandrel_mcp_th

Source
Expand description

§MOTH - MOdel context protocol Test Harness

A modern, comprehensive testing framework for MCP (Model Context Protocol) servers built on the official Rust SDK. MOTH provides validation, compliance testing, and detailed reporting for MCP server implementations.

§Features

  • SDK-First: Built on the official MCP Rust SDK for guaranteed protocol compliance
  • Transport Agnostic: Supports stdio, HTTP, and SSE transports
  • Comprehensive Testing: Protocol compliance, capability validation, and stress testing
  • Rich Reporting: HTML, JSON, and JUnit XML report formats
  • Developer Friendly: Clear error messages, detailed logs, and interactive CLI

§Architecture

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│   Config    │───▶│   Client    │───▶│  Executor   │
│  (YAML)     │    │ (MCP/rmcp)  │    │ (Test Run)  │
└─────────────┘    └─────────────┘    └─────────────┘
       │                   │                   │
       ▼                   ▼                   ▼
┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ Validation  │    │   Server    │    │  Reporting  │
│  (Schema)   │    │ (Process)   │    │ (JSON/HTML) │
└─────────────┘    └─────────────┘    └─────────────┘

§Quick Start

use mandrel_mcp_th::cli::{Cli, Commands};
use clap::Parser;

let cli = Cli::parse();
match cli.command {
    Commands::Run(run_args) => {
        // Test execution logic
        println!("Running tests from: {}", run_args.config.display());
    }
    Commands::Report(report_args) => {
        // Report generation logic
        println!("Generating reports from: {}", report_args.input.display());
    }
    Commands::Validate(validate_args) => {
        // Configuration validation
        println!("Validating config: {}", validate_args.config.display());
    }
    Commands::Profile(_profile_args) => {
        // Profile management
        println!("Managing configuration profiles");
    }
    Commands::Watch(_watch_args) => {
        // File watching and auto-generation
        println!("Starting file watch mode");
    }
}

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

cli
Command-line interface for Mandrel MCP Test Harness
client
MCP client module
error
Error types for MOTH test harness
error_handling
Comprehensive Error Handling and Logging System
executor
reporting
Test reporting module
runner
Test Suite Runner - Orchestrates multiple test case executions
script_engines
Script execution engines for validation scripts
spec
YAML specification parser and validation module
testing
Testing infrastructure for MOTH
validation
Protocol validation module

Constants§

DEFAULT_MAX_CONCURRENCY
Maximum concurrent test executions by default
DEFAULT_TIMEOUT_SECS
Default timeout for MCP operations
FULL_NAME
The full name
MCP_PROTOCOL_VERSION
The MCP protocol version this harness supports
NAME
The name of the test harness
VERSION
The version of MOTH

Functions§

init_logging
Configuration for logging
is_dev_version
Check if the version has been patched with a patch If patched, the version will have a -dev suffix
is_shutdown_requested
Check if shutdown has been requested
request_shutdown
Request shutdown (used by signal handlers)
user_agent
Returns the user agent string for HTTP requests