
The MCP Engineer Handbook
概览
This repository has the code samples for MCP Engineering Handbook by Peder Holdgaard Pedersen (Packt, 2026). The samples target the and the v2 SDKs. Most samples come in C#, Python and TypeScript. The book prints one of them, marked in the table below. The other two are ports that behave the same way, so you can follow along in the language you prefer. Each sample's README says what it demonstrates, which section of the book it belongs to, how to run it, and the versions it was tested with. A few samples call a hosted model and need an API key. Their READMEs say which and how to set it. 1. Clone the repository and pick a sample from the table below, or start with templates/hello-server, a minimal server in all three languages that checks your toolchain. 2. Run it as its README describes. For a stdio server, that is usually one of these: 3.
README
以下为原文 README 节选,完整内容请查看原文。
MCP Engineering Handbook — Companion Samples
This repository has the code samples for MCP Engineering Handbook by Peder Holdgaard Pedersen (Packt, 2026). The samples target the 2026-07-28 revision of the Model Context Protocol and the v2 SDKs.
Most samples come in C#, Python and TypeScript. The book prints one of them, marked canonical in the table below. The other two are ports that behave the same way, so you can follow along in the language you prefer. Each sample’s README says what it demonstrates, which section of the book it belongs to, how to run it, and the versions it was tested with.
Prerequisites
| Tool | Version | Used for |
|---|---|---|
| .NET SDK | 10 | C# samples |
| uv | current | Python samples (each project pins its own interpreter, 3.12 or later) |
| Node.js | 24 LTS (20 or later for the TypeScript samples alone) | TypeScript samples, the MCP Inspector (needs 22.19 or later) and the everything server (needs 24) |
| Ollama | current | chapter01/client (ollama pull qwen3:1.7b) |
A few samples call a hosted model and need an API key. Their READMEs say which and how to set it.
Getting started
-
Clone the repository and pick a sample from the table below, or start with
templates/hello-server, a minimal server in all three languages that checks your toolchain. -
Run it as its README describes. For a stdio server, that is usually one of these:
cd csharp && dotnet run cd python && uv run python server.py cd typescript && npm ci && npm run build && npm start -
To explore a server interactively, use the MCP Inspector, the version shown in the book:
npx @modelcontextprotocol/[email protected]Add the server with Add Servers > Add manually, using the same command you’d run it with, then open the server’s Settings and set Protocol Era to Auto before you connect. The Inspector defaults to the legacy 2025-11-25 handshake, so without this step you won’t see the 2026-07-28 protocol the samples are written for.
Layout
chapterNN//
README.md what it demonstrates, the book section, how to run it, tested versions
csharp/ .NET 10: dotnet run
python/ uv: uv run python .py
typescript/ Node, ESM: npm ci && npm run build && npm start
templates/ walking skeletons (hello-server, hello-client) in all three languages
Samples
Chapters 4, 8, 11 and 13 have no samples: they cover transports, architectures, security and the protocol’s future in prose and diagrams rather than runnable code.
| Sample | Book section | Languages |
|---|---|---|
chapter01/stdio-server/ |
§1.7 | C# (canonical), Python, TS |
chapter01/http-server/ |
§1.7–1.8 | C# (canonical), Python, TS |
chapter01/client/ |
§1.8 | C# only (by design; Ollama-wired, LLM API alternatives included) |
chapter02/long-running-operation/ |
§2.6.4 | C# (canonical), Python, TS |
安装
npx @modelcontextprotocol/[email protected]