Skip to content
Clean Model Context Protocol
Lean Mean Clean Apps

Five templates, one brand, one search box. Everything in the docs is in here, including the bits we hoped you'd skim.

Try one of these

Results say which template they came from, so you won't end up reading about Lambda when you wanted GraphQL. Again.

Test your changes

Your solution starts with four test projects and a pipeline that fails under 95% line coverage. That number isn’t the goal, it’s the floor. The goal is that every behaviour you add has a test that would fail if someone broke it, including you, six months from now.

Project What it tests How
tests/Application.Tests.Unit Handlers, validators and pipeline behaviours xUnit, Shouldly and NSubstitute, with the repositories substituted
tests/Infrastructure.Tests.Integration The repositories against a real database A private in-memory SQLite database per test, built from the migrations and the fixed seed
tests/Presentation.Tests.Unit Tools, the result mapper and the error filters Plain unit tests, no host
tests/Presentation.Tests.Integration A real MCP client calling tools, resources, prompts and completions, plus OAuth and health checks WebApplicationFactory and the MCP C# SDK client

Rule of thumb: test a rule where it lives. A validation rule gets a validator test, a query’s filter gets a repository test, and what a client sees from a tool gets an integration test through the MCP client.

Every test has // Arrange, // Act and // Assert sections, tests one behaviour, and is named Method_Should<Outcome>_<Condition>, so a failure reads as a sentence.

Code Prove it works Prove it says no
Validator A valid request has no errors, and each boundary value passes One failing case per rule, asserting the message, and each value just outside a boundary
Handler The happy path returns the result and passes the values and the cancellation token to the repository Each documented failure throws the right exception, and nothing after it runs
Repository The right rows come back or change, in order, with paging and search applied Unknown ids return null or false, and nothing else changes
Tool, resource or prompt One test per documented success One test per documented failure, with the error checked

For ranges, test both sides of each edge: stars 1 and 5 pass, 0 and 6 fail. A [Theory] with [InlineData] keeps that to one test.

tests/Application.Tests.Unit/Reviews/Commands/CreateReview/CreateReviewValidatorTests.cs
[Theory]
[InlineData(-1)]
[InlineData(0)]
[InlineData(6)]
public void Validator_ShouldHaveValidationErrorFor_Stars(int stars)
Terminal window
dotnet test

No test shares a database with another, so they run in parallel and never trip over each other. Nothing touches movie-reviews.db either, so your local data survives a test run.

CI merges the coverage of all four projects into one total and fails under 95%. Run the same measurement from the solution root:

Terminal window
dotnet test -m:1 \
-p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" \
-p:CoverletOutputFormat=opencover%2cjson \
-p:ExcludeByFile="**/Program.cs%2c**/Migrations/*.cs%2c**/obj/**/*.cs" \
-p:ExcludeByAttribute="GeneratedCodeAttribute"

The last table it prints is the merged total. Program.cs, the EF Core migrations and source-generated code are left out on purpose. Everything else counts.

  • Add a tool ends with a test for the new tool.
  • Make it yours adds a whole entity, then clears the sample out without dropping under the coverage gate.
  • Work with a coding agent: the test-design, unit-tests, integration-tests and coverage skills hold these same rules, so an agent writes tests the same way you would.