mcpkit_testing/
lib.rs

1//! Testing utilities for the MCP SDK.
2//!
3//! This crate provides mocks, fixtures, and assertions for testing MCP servers
4//! and clients. It includes:
5//!
6//! - Mock servers and clients for unit testing
7//! - Test fixtures with pre-configured tools/resources
8//! - Custom assertions for MCP-specific scenarios
9//!
10//! # Overview
11//!
12//! ## Mock Server
13//!
14//! ```rust
15//! use mcpkit_testing::{MockServer, MockTool};
16//! use mcpkit_core::types::ToolOutput;
17//!
18//! let server = MockServer::new()
19//!     .tool(MockTool::new("add")
20//!         .description("Add two numbers")
21//!         .handler(|args| Ok(ToolOutput::text("42"))))
22//!     .build();
23//!
24//! // Use in tests with MemoryTransport
25//! ```
26//!
27//! ## Test Fixtures
28//!
29//! ```rust
30//! use mcpkit_testing::fixtures;
31//!
32//! let tools = fixtures::sample_tools();
33//! let resources = fixtures::sample_resources();
34//! ```
35//!
36//! ## Assertions
37//!
38//! ```rust
39//! use mcpkit_testing::assert_tool_result;
40//! use mcpkit_core::types::CallToolResult;
41//!
42//! let result = CallToolResult::text("42");
43//! assert_tool_result!(result, "42");
44//! ```
45
46#![deny(missing_docs)]
47#![warn(clippy::all)]
48#![warn(clippy::pedantic)]
49#![warn(clippy::unwrap_used)]
50#![warn(clippy::must_use_candidate)]
51#![allow(clippy::module_name_repetitions)]
52
53pub mod assertions;
54pub mod fixtures;
55pub mod mock;
56
57// Re-export commonly used types
58pub use assertions::{assert_tool_error, assert_tool_success};
59pub use fixtures::{sample_resources, sample_tools};
60pub use mock::{MockServer, MockServerBuilder, MockTool};
61
62/// Prelude module for convenient imports.
63pub mod prelude {
64    pub use crate::assertions::{assert_tool_error, assert_tool_success};
65    pub use crate::fixtures::{sample_resources, sample_tools};
66    pub use crate::mock::{MockServer, MockServerBuilder, MockTool};
67}