10 releases (4 breaking)
Uses new Rust 2024
| 0.5.0 | Dec 26, 2025 |
|---|---|
| 0.4.0 | Dec 24, 2025 |
| 0.3.0 | Dec 23, 2025 |
| 0.2.5 | Dec 17, 2025 |
| 0.1.0 | Dec 11, 2025 |
#416 in Testing
1MB
23K
SLoC
mcpkit-testing
Testing utilities for the Model Context Protocol (MCP).
This crate provides mocks, fixtures, and assertions for testing MCP servers and clients.
Features
- Mock servers and clients for unit testing
- Test fixtures with pre-configured tools/resources
- Custom assertions for MCP-specific scenarios
Usage
Mock Server
use mcpkit_testing::{MockServer, MockTool};
use mcpkit_core::types::ToolOutput;
let server = MockServer::new()
.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");
Exports
| Export | Purpose |
|---|---|
MockServer |
Mock MCP server for testing |
MockServerBuilder |
Builder for mock servers |
MockTool |
Mock tool definition |
assert_tool_success |
Assert tool call succeeded |
assert_tool_error |
Assert tool call failed |
sample_tools |
Pre-configured test tools |
sample_resources |
Pre-configured test resources |
Part of mcpkit
This crate is part of the mcpkit SDK. For most use cases, depend on mcpkit directly rather than this crate.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Dependencies
~24MB
~354K SLoC