📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you test an MCP server in .NET, both its tool schemas and its behaviour, before connecting a real AI host?

Mid-Level Coding Intermediate

🎯 Key points

  • Tools are plain classes: unit-test them directly, including edge and hostile inputs
  • WebApplicationFactory + McpClient for protocol-level tests
  • Snapshot ListToolsAsync output to catch schema drift
  • Assert result content and error messages, not only schema
  • Test 401/403 and cross-user refusal
  • Load-test the endpoint against a p95 latency target
  • Evaluation set against a real model for tool selection

⏱ 30-second answer

Unit-test the tool classes directly as ordinary C# (they are plain methods with DI dependencies), including edge cases: invalid formats, out-of-range numbers, missing records, over-long strings, and inputs that look like instructions. For the protocol, host the server in WebApplicationFactory and connect an McpClient over the test server's HTTP handler, then snapshot ListToolsAsync (names, descriptions, schemas, annotations) so accidental schema changes fail CI, and call tools to assert on result content and error messages, not just shape. Add authorisation tests (no token → 401, wrong scope → 403, another user's data → refused). Load-test the HTTP endpoint (for example with k6 or NBomber) against a latency target, since hosts call tools inside a user's wait. Finally run an evaluation set of user tasks against a real model to check tool selection, because a description change can break the model's choices without breaking any code.

🔍 What the interviewer is checking

Checks automated testing of MCP tools and schema stability

↩ Usually asked after

More in AI Agents and MCP

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me