Test C# MCP servers at two levels: unit tests for individual tool methods, and integration tests that exercise the full MCP protocol in-memory using the MCP client SDK.
Tasks
Create an xUnit test project, reference the server .csproj, and add ModelContextProtocol, Moq, and FluentAssertions packages
Write unit tests for individual tool methods, including edge cases and mocked DI dependencies using HttpMessageHandler
Inputs
MCP server project path (required)
Test framework (recommended; default: xUnit; also supports NUnit or MSTest)
Transport type (recommended; determines integration test approach: stdio vs HTTP)
Outputs
Unit tests for individual tool methods
Integration tests validating MCP protocol tool listing and invocation
Evaluations measuring how well an LLM uses the server's tools
Limitations and checks
Do not use for testing MCP clients; this skill is for server testing only
Do not use for load or performance testing
Do not use for testing non-.NET MCP servers
Do not use for debugging server issues; use mcp-csharp-debug instead
Unit tests cover all tool methods, including edge cases
Integration tests verify tool listing via ListToolsAsync()
Integration tests verify tool invocation via CallToolAsync()