Expand description
Testing utilities for the MCP SDK.
This crate provides mocks, fixtures, and assertions for testing MCP servers and clients. It includes:
- Mock servers and clients for unit testing
- Test fixtures with pre-configured tools/resources
- Custom assertions for MCP-specific scenarios
§Overview
§Mock Server
use mcpkit_testing::{MockServer, MockTool};
use mcpkit_core::types::ToolOutput;
let server = MockServer::builder()
.tool(MockTool::new("add")
.description("Add two numbers")
.handler(|args| Ok(ToolOutput::text("42"))))
.build();
// Use in tests with MemoryTransport§Test Fixtures
use mcpkit_testing::fixtures;
let tools = fixtures::sample_tools();
let resources = fixtures::sample_resources();§Assertions
use mcpkit_testing::assert_tool_result;
use mcpkit_core::types::CallToolResult;
let result = CallToolResult::text("42");
assert_tool_result!(result, "42");Re-exports§
pub use assertions::assert_tool_error;pub use assertions::assert_tool_success;pub use fixtures::sample_resources;pub use fixtures::sample_tools;pub use mock::MockServer;pub use mock::MockServerBuilder;pub use mock::MockTool;
Modules§
- assertions
- Custom assertions for MCP testing.
- fixtures
- Test fixtures for MCP testing.
- mock
- Mock implementations for testing.
- prelude
- Prelude module for convenient imports.
Macros§
- assert_
tool_ error_ msg - Macro for asserting tool result error.
- assert_
tool_ result - Macro for asserting tool result success.