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::builder()
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
48pub mod assertions;
49pub mod fixtures;
50pub mod mock;
51
52// Re-export commonly used types
53pub use assertions::{assert_tool_error, assert_tool_success};
54pub use fixtures::{sample_resources, sample_tools};
55pub use mock::{MockServer, MockServerBuilder, MockTool};
56
57/// Prelude module for convenient imports.
58pub mod prelude {
59    pub use crate::assertions::{assert_tool_error, assert_tool_success};
60    pub use crate::fixtures::{sample_resources, sample_tools};
61    pub use crate::mock::{MockServer, MockServerBuilder, MockTool};
62}