McpServerFactory.Xunit
0.2.0
dotnet add package McpServerFactory.Xunit --version 0.2.0
NuGet\Install-Package McpServerFactory.Xunit -Version 0.2.0
<PackageReference Include="McpServerFactory.Xunit" Version="0.2.0" />
<PackageVersion Include="McpServerFactory.Xunit" Version="0.2.0" />
<PackageReference Include="McpServerFactory.Xunit" />
paket add McpServerFactory.Xunit --version 0.2.0
#r "nuget: McpServerFactory.Xunit, 0.2.0"
#:package McpServerFactory.Xunit@0.2.0
#addin nuget:?package=McpServerFactory.Xunit&version=0.2.0
#tool nuget:?package=McpServerFactory.Xunit&version=0.2.0
McpServerFactory.Xunit
xUnit fixtures for McpServerFactory — boot an
in-memory MCP server once per test class and share the connected client through
IClassFixture<T>, the same pattern you would use with WebApplicationFactory<T> in ASP.NET Core
integration tests.
dotnet add package McpServerFactory.Xunit
Usage
using McpServerFactory.Testing;
using McpServerFactory.Testing.Xunit;
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.Server;
public sealed class CalculatorFixture : McpServerFixture
{
protected override void ConfigureMcpServer(IMcpServerBuilder builder) =>
builder.WithTools<CalculatorTools>();
}
public sealed class CalculatorTests(CalculatorFixture fixture) : IClassFixture<CalculatorFixture>
{
[Fact]
public async Task Add_ReturnsSum()
{
string result = await fixture.TestClient.CallToolForTextAsync(
"add",
new Dictionary<string, object?> { ["a"] = 1, ["b"] = 2 });
Assert.Equal("3", result);
}
}
The server boots once in InitializeAsync and is disposed in DisposeAsync. Override
ConfigureServices, ConfigureMcpServer, or CreateOptions to substitute dependencies, register
tools/resources/prompts, or wire client handlers (for example a FakeSamplingHandler).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 is compatible. 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. |
-
net10.0
- McpServerFactory (>= 0.2.0)
- xunit.core (>= 2.9.3)
-
net8.0
- McpServerFactory (>= 0.2.0)
- xunit.core (>= 2.9.3)
-
net9.0
- McpServerFactory (>= 0.2.0)
- xunit.core (>= 2.9.3)
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 |
|---|---|---|
| 0.2.0 | 0 | 6/5/2026 |