| name | mcp-csharp-test |
| description | Use when testing a C# MCP server's tools, stateless HTTP endpoint, MRTR retries, tasks, Apps metadata, or conformance behavior. |
| license | MIT |
| version | 0.2.0 |
C# MCP Server Testing
Derived from dotnet/skills under MIT; updated for ModelContextProtocol 2.0.0 and MCP 2026-07-28. See ../../THIRD-PARTY-NOTICES.md.
Test observable contracts at three levels:
- Unit-test tool logic with real validation boundaries and deterministic dependencies.
- Test stdio or
WebApplicationFactory integration through the SDK client; verify listing and invocation, not private registration details.
- Start the real stateless HTTP endpoint; test its 2026 contract directly. Use
$mcp-conformance only for its supported 2025/draft wire coverage.
Modern HTTP cases
- Every HTTP request supplies request
_meta and a matching Mcp-Method; every POST supplies matching MCP-Protocol-Version. Test that missing capability fails the relevant request, not a later session call.
- Assert an
MCP-Protocol-Version/body or Mcp-Method/body mismatch returns -32020.
- Assert a required capability failure returns
-32021; unsupported revision returns -32022.
- Assert legacy
initialize, session GET/DELETE, and accidental Mcp-Session-Id behavior are rejected or intentionally routed according to the endpoint policy.
MRTR and Tasks
For MRTR, invoke a tool that returns/throws InputRequiredResult/InputRequiredException, then reissue the original request with a new JSON-RPC ID and inputResponses. Verify sealed requestState is rejected if altered. For Tasks, reference ModelContextProtocol.Extensions.Tasks, configure an IMcpTaskStore with WithTasks(store), create a task, and observe its explicit lifecycle update; do not test it as a tool retry.
Apps and AOT
Verify that an Apps-enabled tool advertises the intended ui:// resource metadata and visibility. Build the AOT configuration to prove explicit WithTools<T>() registration replaces assembly scanning.
Commands
dotnet test
dotnet publish -p:PublishAot=true
Use focused tests while iterating; run the complete affected suite before delivery. $mcp-conformance owns supported legacy/draft wire coverage, while this skill owns modern and application semantics.