mcp-csharp-test

Test C# MCP servers with unit tests and in-memory protocol integration tests.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill mcp-csharp-test-ecodriverltd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mcp-csharp-test
Source: https://github.com/ecoDriverltd/FoundryAgentsExperiment/tree/main/.agents/skills/mcp-csharp-test
Command: npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill mcp-csharp-test-ecodriverltd

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building an MCP server in C# is only half the job — without automated tests, you cannot verify that tools behave correctly, that the server lists and invokes tools properly over the MCP protocol, or that changes don't break existing behavior. This Skill provides a complete testing workflow for .NET MCP servers, from isolated unit tests to full protocol-level 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 HttpMessageHandler. - Integration Testing via MCP Protocol: Validate tool listing with ListToolsAsync and invocation with CallToolAsync using the MCP client SDK, in-memory ClientServerTestBase, or WebApplicationFactory for HTTP servers. - Evaluations for LLM Tool Use: Design read-only, deterministic evaluation questions in XML format to measure how well an LLM uses your server's tools. - Use Case: You built a product catalog MCP server and want CI coverage. Use this Skill to scaffold a test project, write unit tests for each tool, add in-memory integration tests verifying the protocol, and author evaluation questions for quality measurement. ## Quick Start Ask the AI to write unit and integration tests for your C# MCP server project using 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 as plain C# methods using xUnit and FluentAssertions, mocking dependencies with Moq or a custom HttpMessageHandler for HttpClient-based tools. This gives fast, isolated coverage without starting a server.

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

Use the MCP client SDK's McpClient with StdioClientTransport to spawn your server, then verify ListToolsAsync and CallToolAsync behavior. For faster tests, use ClientServerTestBase for in-memory transport or WebApplicationFactory for HTTP servers.

Can I test HTTP MCP servers with WebApplicationFactory?▼

Yes, WebApplicationFactory works with HTTP MCP servers by posting JSON-RPC initialize and tools/call requests to the MCP endpoint. The server must expose its Program class via InternalsVisibleTo or a public partial Program declaration.

Why does my MCP integration test hang on CreateAsync?▼

CreateAsync hangs when the server fails to start, usually because the project does not build or stdout logging corrupts the stdio transport. Run dotnet build first and ensure no console output interferes with the protocol stream.

What are good evaluation questions for MCP server tools?▼

Good evaluation questions are read-only, deterministic, and require multi-step reasoning across several tool calls, such as comparing values across categories. Answers must contain exact verifiable values so results can be checked programmatically.