About McpServerFactory templates
McpServerFactory templates is an MCP server published by diomonogatari in the Developer Tools category: dotnet new templates for bootstrapping MCP server integration tests using McpServerFactory.
The repository has 1 stars and 0 forks, with the last commit 4 months ago. Recent commit activity is the strongest signal that reported issues will get attention.
Install
git clone https://github.com/diomonogatari/mcp-server-factoryThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about McpServerFactory templates
Powered by Claude · Grounded in docs
Security checks
- ✓README presentThe repository ships documentation.
5 checks have not been run yet.
README
McpServerFactory
In-memory integration testing factory for .NET Model Context Protocol (MCP) servers.
McpServerFactory gives .NET MCP servers a testing experience similar in spirit to
WebApplicationFactory<T> for ASP.NET Core. It boots an MCP server in-process,
connects a real McpClient through in-memory streams, and lets you run realistic
integration tests without network ports, Docker, or external services.
Installation
dotnet add package McpServerFactory
Template-based scaffolding
Install the template pack to bootstrap an MCP integration test project:
dotnet new install McpServerFactory.Templates
dotnet new mcp-itest -n MyServer.Tests
The mcp-itest template accepts --McpServerFactoryVersion to override the
package version (default 0.1.0).
Quick start
using McpServerFactory.Testing;
using ModelContextProtocol.Server;
[McpServerToolType]
public sealed class EchoTools
{
[McpServerTool(Name = "echo")]
public string Echo(string message)
{
return message;
}
}
await using var factory = new McpServerIntegrationFactory(
configureMcpServer: builder => builder.WithTools<EchoTools>());
await using var client = await factory.CreateClientAsync();
var result = await client.CallToolAsync(
"echo",
arguments: new Dictionary<string, object?> { ["message"] = "hello" });
Why use this library
- In-memory transport using the MCP SDK's public stream APIs.
- Real MCP protocol flow (
tools/list,tools/call) in tests. - Easy dependency overrides through
configureServicesandConfigureServices. - Framework-agnostic library (works with xUnit, NUnit, MSTest, etc.).
Behavioral guarantees
CreateClientAsyncis thread-safe and idempotent per factory instance.- Concurrent calls return the same connected
McpClientinstance. - Startup failures do not leak the temporary host instance.
DisposeAsyncis safe to call multiple times.CreateClientAsyncthrowsObjectDisposedExceptionafter disposal.
Compatibility and support
- Target framework:
net10.0. - MCP SDK dependency:
ModelContextProtocol0.4.0-preview.3. - Compatibility promise: each package release is validated against the pinned MCP SDK version.
- Upgrade policy: MCP SDK bumps are explicit and called out in CHANGELOG.md.
API overview
McpServerFactory- Backward-compatible factory entry point.
McpServerIntegrationFactory- Preferred factory type for new code.
- Starts an in-process server host.
- Creates a connected
McpClientviaCreateClientAsync(). - Exposes
Servicesfor DI validation after startup.
McpServerFactoryOptions- Configure server identity, startup/disposal timeouts, and instructions.
- Suppress host logging by default and optionally customize logging.
McpTestClient- Convenience wrapper for common test operations.
Logging in test output
By default, host logging providers are suppressed to keep test output clean. To enable custom logging during tests:
using Microsoft.Extensions.Logging;
var options = new McpServerFactoryOptions
{
SuppressHostLogging = false,
ConfigureLogging = logging => logging.SetMinimumLevel(LogLevel.Debug),
};
Release notes
See CHANGELOG.md for release history and upcoming changes.
Samples
- Minimal runnable sample:
samples/MinimalSmoke
Repository layout
src/McpServerFactory— reusable factory library.tests/McpServerFactory.Tests— unit/integration-focused library tests.templates/McpServerFactory.Templates—dotnet newtemplate pack.samples/MinimalSmoke— runnable sample console app.docs— architecture notes and usage guidance.
README copy captured when this server was indexed; it may lag the repository. The original is authoritative.