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.

Get started

By the end of this page you’ll have your own solution, an MCP server running on your machine, and a tool answering back. It takes about five minutes, or ten if NuGet decides to download the internet first.

You need the .NET 10 SDK. Docker is optional, but it gets you the MCP Inspector and the Aspire dashboard without installing anything else, so it’s worth having around.

  1. Install the template from NuGet.

    Terminal window
    dotnet new install CleanModelContextProtocol.Template
  2. Create a solution. The name becomes your namespace, project names and folder, so pick something you’re happy to see a lot of.

    Terminal window
    dotnet new cleanmodelcontextprotocol --name WorksOnMyMachine.Movies --authorName "Your Name"
    cd WorksOnMyMachine.Movies

    Rather click? The template shows up in the new project dialog in Visual Studio and Rider with the same options. Fill them in properly. You never know who’s reading and handing out .NET Rocks mugs… Hi Richard!

    If the dialog asks for a solution format, pick .slnx, which is what the template makes. Some versions of Visual Studio and Rider still write a second solution file next to it. If you end up with two, open the .slnx and delete the other one.

  3. Have a look around. Everything you need is already here.

    • WorksOnMyMachine.Movies.slnx
    • Dockerfile
    • docker-compose.yml
    • Directorysrc/
      • DirectoryApplication/ the rules, queries and validation
        • …
      • DirectoryInfrastructure/ the database and repositories
        • …
      • DirectoryPresentation/ the tools, resources and prompts
        • …
    • Directorytests/
      • DirectoryApplication.Tests.Unit/
        • …
      • DirectoryInfrastructure.Tests.Integration/
        • …
      • DirectoryPresentation.Tests.Integration/
        • …
      • DirectoryPresentation.Tests.Unit/
        • …
  4. Run it. The local environment seeds sample data and logs to the console, so there’s nothing to set up.

    Terminal window
    dotnet run --project ./src/Presentation

    It answers on https://localhost:7321. If your browser or curl doesn’t trust the .NET development certificate yet, run dotnet dev-certs https --trust once.

  5. Call a tool. The server speaks Streamable HTTP at /mcp, and because it’s stateless you can send a single JSON-RPC request with nothing before it.

    Terminal window
    curl -X POST "https://localhost:7321/mcp" \
    -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
    -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"movies_search","arguments":{"query":"space","limit":2}}}'

    The answer arrives as a server-sent event. Inside it, the tool’s result is there twice: once as text for models that read, once as structuredContent for clients that parse. A resource_link for each movie follows the text, so a client can open it as a resource.

    {
    "items": [
    { "id": "cb188ef6-14e7-f85f-2f78-924c2ab26b28", "title": "Deep Space Gardeners", "reviewCount": 5, "averageStars": 3.4, "reviews": null },
    { "id": "dfefa450-5454-6a4d-a4aa-95a9b047c17b", "title": "Postcards from Outer Space", "reviewCount": 1, "averageStars": 3, "reviews": null }
    ],
    "totalCount": 4,
    "nextOffset": 2
    }

    The sample movies are all made up. Deep Space Gardeners averages 3.4 stars from five reviews, which seems fair for a film about weeding in zero gravity.

  6. Or skip curl and use the Inspector. Docker Compose starts it already pointed at the server.

    Terminal window
    docker compose up -d --build

    Open http://localhost:7325, connect, and the Tools, Resources and Prompts tabs show everything the server offers, with a form for each.

  7. Run the tests while you’re here.

    Terminal window
    dotnet test

Hit a snag? Check Troubleshooting.