Add sampling to a .NET MCP server | Model Context Protocol Tutorial

Authorised Territory demonstrates how to add sampling to a .NET Model Context Protocol (MCP) server so an MCP tool can call back into a client’s locally running LLM (via Ollama) using a chat client.

Overview

This tutorial shows how to implement sampling support in a .NET MCP server.

The starting solution for this tutorial is referenced here: