RJO.ModelContextProtocol.Testing
1.0.0-preview.1
This is a prerelease version of RJO.ModelContextProtocol.Testing.
dotnet add package RJO.ModelContextProtocol.Testing --version 1.0.0-preview.1
NuGet\Install-Package RJO.ModelContextProtocol.Testing -Version 1.0.0-preview.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RJO.ModelContextProtocol.Testing" Version="1.0.0-preview.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RJO.ModelContextProtocol.Testing" Version="1.0.0-preview.1" />
<PackageReference Include="RJO.ModelContextProtocol.Testing" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RJO.ModelContextProtocol.Testing --version 1.0.0-preview.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RJO.ModelContextProtocol.Testing, 1.0.0-preview.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RJO.ModelContextProtocol.Testing@1.0.0-preview.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RJO.ModelContextProtocol.Testing&version=1.0.0-preview.1&prerelease
#tool nuget:?package=RJO.ModelContextProtocol.Testing&version=1.0.0-preview.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MCP C# Testing Harness
A comprehensive testing framework for the Model Context Protocol (MCP) C# SDK that enables thorough unit and integration testing without requiring separate processes or network communication.
Features
- In-Process Testing: All components run in the same process for fast test execution (< 100ms per typical test)
- Message Capture: Records all protocol messages with comprehensive analysis and filtering
- Test Doubles: Configurable mock implementations of IMcpServer and IMcpClient with fluent APIs
- NUnit Integration: Custom attributes, specialized assertions, and base test fixtures
- Performance Testing: Built-in performance measurement, load testing, and stress testing capabilities
- Man-in-the-Middle Testing: Message interception, modification, and protocol compliance verification
- Test Data Builders: Fluent builders for creating MCP protocol objects with realistic test data
- Test Context Management: Metadata tracking, step recording, and comprehensive test summaries
Quick Start
[Test]
public class MyToolTests : McpToolTestFixture<MyTool>
{
[McpTest]
public async Task TestMyTool()
{
var result = await InvokeToolAsync<Content>("my-tool", new { input = "test" });
McpAssert.IsValidToolResult(result);
Assert.That(result.Content[0].Text, Contains.Substring("expected"));
}
}
Installation
dotnet add package ModelContextProtocol.Testing
Documentation
For complete documentation, see the /testingharness/ directory in the main repository.
Requirements
- .NET 9.0 or later
- ModelContextProtocol SDK v0.2.0-preview.1
- NUnit 3.14+
- FluentAssertions 6.12+ (for enhanced test assertions)
Current Status
✅ Production Ready - All 9 implementation phases completed:
- 294 tests passing with 100% success rate
- Full feature coverage including performance testing, message interception, and test utilities
- Comprehensive examples demonstrating all major features
- Performance optimized with minimal test execution overhead
- Memory leak tested with proper disposal patterns
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- FluentAssertions (>= 6.12.0)
- ModelContextProtocol (>= 0.2.0-preview.1)
- NUnit (>= 3.14.0)
- System.Text.Json (>= 8.0.5)
- System.Threading.Channels (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.1 | 113 | 5/30/2025 |