mcp-csharp-test

Test C# MCP servers with unit tests and in-memory integration tests via the MCP client SDK.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill mcp-csharp-test-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mcp-csharp-test
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/mcp-csharp-test
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill mcp-csharp-test-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building an MCP server in C# is only half the work — without automated tests you cannot verify that tools list correctly, return expected results, or survive refactors. This Skill provides a complete testing workflow for .NET MCP servers, from isolated unit tests to full MCP protocol integration tests. ## Core Features & Use Cases - Unit Testing of Tool Methods: Test individual MCP tool methods directly with xUnit, Moq, and FluentAssertions, including mocking HttpClient dependencies via a reusable MockHttpMessageHandler. - Integration Testing via MCP Protocol: Validate tool listing with ListToolsAsync and invocation with CallToolAsync using StdioClientTransport, the SDK's in-memory ClientServerTestBase, or WebApplicationFactory for HTTP servers. - Evaluations for Tool Quality: Design read-only, deterministic, multi-step evaluation questions in XML qa_pair format to measure how well an LLM uses your tools. - Use Case: You just scaffolded a product-catalog MCP server and need CI-ready tests. This Skill walks you through creating the test project, writing unit and integration tests, and adding evaluation questions. ## Quick Start Ask the AI to create unit and integration tests for your C# MCP server project, covering tool listing, tool invocation, and edge cases with xUnit and the MCP client SDK.

Frequently Asked Questions about mcp-csharp-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I unit test MCP server tools in C#?

Test MCP tool methods directly by calling them like normal C# methods with xUnit and FluentAssertions. For tools with dependencies like HttpClient, mock the HttpMessageHandler rather than HttpClient itself to control responses.

How to write integration tests for a .NET MCP server?

Use the MCP client SDK's StdioClientTransport to spawn your server and verify ListToolsAsync and CallToolAsync behavior. For faster tests, use the SDK's ClientServerTestBase for in-memory testing with full DI support and no process spawning.

Can I test an HTTP MCP server with WebApplicationFactory?

Yes, WebApplicationFactory works for HTTP MCP servers, but the Program class must be accessible. Either add InternalsVisibleTo for your test project in the server csproj or declare Program as a public partial class.

Why does my MCP integration test hang on CreateAsync?

CreateAsync hangs when the server fails to start. Verify dotnet build succeeds first, and for stdio transports ensure nothing writes logging output to stdout, which corrupts the MCP protocol stream.

What makes a good evaluation question for MCP tools?

Good evaluation questions are read-only, deterministic, and multi-step, requiring the LLM to call multiple tools and reason across results. Answers must contain exact verifiable values like counts, names, or prices.

When should I not use this MCP server testing approach?

This Skill covers server-side testing only, not MCP client testing, and targets .NET servers exclusively. It is also not suited for load or performance testing; use mcp-csharp-debug for interactive debugging instead.