vibe_tests/lib.rs
1//! VibeTests — integration test framework for MCP servers.
2//! Let AI models test your MCP tools automatically.
3//!
4//! # Usage
5//!
6//! ```rust,ignore
7//! use std::collections::HashMap;
8//! use std::process::Command;
9//! use std::time::Duration;
10//! use tracing::Level;
11//! use vibe_tests::EngineTests;
12//!
13//! // Configure test engine with MCP server and Ollama
14//! vibe_tests::engine_config! {
15//! EngineTests::builder()
16//! // Docker compose for infrastructure (optional)
17//! .compose_file("docker-compose.yml")
18//! // Your MCP server URL
19//! .mcp_host("http://localhost:9021/mcp/v1")
20//! // Ollama API endpoint
21//! .ollama_host("http://localhost:11434")
22//! // Models to test
23//! .ollama_models(&["qwen2.5-coder:3b-instruct"])
24//! // Ensure full GPU memory for the model
25//! .ollama_exclusive(true)
26//! // One-time setup: start MCP server and prepare test data
27//! .on_start(|env| async move {
28//! // Start your MCP server
29//! let child = Command::new("my-mcp-server")
30//! .stdout(env.tee.clone())
31//! .stderr(env.tee.clone())
32//! .spawn()
33//! .expect("Failed to start MCP server");
34//!
35//! // Return data to on_stop
36//! Ok(Some(HashMap::from([
37//! ("pid".into(), child.id().to_string())
38//! ])))
39//! })
40//! // Cleanup after tests
41//! .on_stop(|env| {
42//! // Kill MCP server
43//! if let Some(data) = &env.data {
44//! if let Some(pid) = data.get("pid") {
45//! let _ = Command::new("kill").arg("-9").arg(pid).status();
46//! }
47//! }
48//! // Save JSON report
49//! if let Ok(json) = serde_json::to_string_pretty(&env.report) {
50//! std::fs::write("report.json", json).ok();
51//! }
52//! })
53//! // Real-time log output
54//! .on_log(|event| {
55//! println!("{}", event.message)
56//! })
57//! // Filter log output
58//! .log_level(Level::ERROR)
59//! // Timeout for all operations
60//! .timeout(Duration::from_secs(60))
61//! // Build the engine
62//! .build()
63//! .expect("Failed to build engine")
64//! }
65//!
66//! // Test: model calls your MCP tool
67//! #[tokio::test]
68//! async fn test_show_projects() {
69//! // Arrange
70//! let engine = vibe_tests::engine().await;
71//! // Act
72//! let result = engine.test("Show available projects").await;
73//! // Assert
74//! assert!(result.success);
75//! assert!(result.models.iter().all(|m| m.tool.as_deref() == Some("show_projects")));
76//! }
77//! ```
78
79mod docker;
80mod engine;
81mod env;
82mod mcp;
83mod ollama;
84
85pub use ctor;
86pub use tokio;
87pub mod base;
88
89pub use base::engines::engine;
90pub use engine::engine_tests::EngineTests;