A dotnet new template for a Model Context Protocol server using the MCP C# SDK in .NET 10, built with a streamlined Clean Architecture. All the layers you need, none of the ceremony you don't.
It's one of five Lean Mean Clean Apps templates, for Minimal APIs, Model Context Protocol, GraphQL, Web API controllers and AWS Lambda. They share the same Application and Infrastructure layers and differ only in how they face the world. The full docs live at leanmeanclean.dev/mcp.
| Template | Presentation | Package | Docs |
|---|---|---|---|
| Clean Minimal API | ASP.NET Core Minimal APIs | CleanMinimalApi.Template | Docs |
| Clean Model Context Protocol | Model Context Protocol server, you are here | CleanModelContextProtocol.Template | Docs |
| Clean GraphQL API | GraphQL with Hot Chocolate | CleanGraphQLApi.Template | Docs |
| Clean Web API | ASP.NET Core controllers | CleanWebApi.Template | Docs |
| Clean Lambda Function | AWS Lambda | CleanLambdaFunction.Template | Docs |
You need the .NET 10 SDK. Docker is optional, but it's the quickest way to see it running.
# Install the template
dotnet new install CleanModelContextProtocol.Template
# Create a solution
dotnet new cleanmodelcontextprotocol --name WorksOnMyMachine.Movies --authorName "Your Name"
cd WorksOnMyMachine.Moviescleanmcp works too, for anyone who'd rather not type cleanmodelcontextprotocol every time, and so do lmca-mcp and leanmeancleanapps-mcp. dotnet new search leanmeanclean lists the whole family.
| Option | Short | Default | What it does |
|---|---|---|---|
--name |
-n |
The folder's name | Names the solution and its root namespace |
--authorName |
-an |
Stephen Walsh |
Puts your name on the assembly instead of ours |
--include-auth |
Off | Adds OAuth for MCP clients. Leave it out and the server has no auth code at all | |
--include-rate-limiting |
Off | Adds the built-in rate limiter, a fixed window per client IP address, switched on by RateLimiting:PermitLimit |
|
--authority |
-iss |
Empty | Your OAuth authorization server. Required with --include-auth |
--audience |
-aud |
Empty | The audience tokens must be issued for, usually the server's own URL. Required with --include-auth |
--no-restore |
Off | Skips the package restore that normally runs once the solution is created |
Rather click than type? Visual Studio and Rider show the same options in their new project dialogs. They always show the authority and audience fields, but only use them when Include authentication is ticked. In the terminal, dotnet new cleanmodelcontextprotocol --help lists them all.
# Build the image and start it with sample data, plus the MCP Inspector, a collector and the Aspire dashboard
docker compose up -d --build
# Run the tests while you're here
dotnet testThen open the MCP Inspector at http://localhost:7325. It's already pointed at the server at http://localhost:7320/mcp, so flip the switch to connect and open Tools.
On your machine the server is open unless you create it with --include-auth, --authority and --audience, and then /mcp asks for a bearer token and publishes protected resource metadata so clients can sign in. Leave --include-auth out and there's no auth code at all, and a deployed copy refuses to start until you set Authentication:AllowAnonymous.
- Presentation: the MCP server, with six task-shaped tools, resources, prompts and completions over stateless Streamable HTTP
- Application: commands and queries through Mediator, validated by FluentValidation and mapped by Mapperly
- Infrastructure: Entity Framework Core on SQLite, with optional sample data
- Tests: xUnit, Shouldly and NSubstitute, each on its own throwaway database
- Extras: OpenTelemetry traces, metrics and Serilog logs over OTLP, health checks, a Dockerfile that runs as a non-root user, Docker Compose, and a GitHub Actions pipeline that won't let your coverage slip
A new version lands on the 1st of each month, as long as something changed. No changes, no release. We're not here to pad the download stats.
dotnet new update- Docs for guides, a reference and why it's built this way
- GitHub for the code, issues and release notes
- Security policy to report a vulnerability privately
Built by Stephen Walsh in spare time, with strong coffee and a healthy disregard for pomp and ceremony. If this template saves you some time, sponsoring the work keeps all five templates current and the coffee flowing.
