CourseModel Context Protocol · Module 5: Building Servers · part 28 of 83
Part 28 · Module 5: Building Servers

Topic 1: Module 5 at a glance

2 min read·22 Sept 2026

By the end of this module, you'll have:

  • A packaged notes server: notes_assistant/config.py and notes_assistant/server.py, replacing the prototypes from Modules 1 to 4, runnable with python -m notes_assistant.server over stdio or streamable HTTP.
  • A working map of what changed from MCP Python SDK v1 to v2 (FastMCP to MCPServer, snake_case fields, MCPError, Context injection, httpx2, transport options on run()), each item checked against the installed SDK.
  • A long-running tool that reports progress with ctx.report_progress and stops cleanly when the caller cancels, with the real notifications/progress and notifications/cancelled messages captured off the wire.
  • Error handling that gives the model messages it can act on and never leaks internals, with the exact text a client sees for each kind of failure.
  • A pytest suite (unit tests for NoteStore, in-memory client tests run against both protocol eras, progress and cancellation tests) plus the MCP Inspector for interactive debugging.
  • Measured numbers: about 6 ms per in-memory test cycle against about 1.2 s when each test spawns a stdio server, and a 22-test suite that takes about 1.5 s in memory and about 30 s over stdio.

Prerequisites: Modules 1 to 4 (roles, JSON-RPC, transports, tools, resources, prompts). Python 3.11, basic async/await, and pytest basics.

Where we are: In Modules 3 and 4 you grew the server as single-file prototypes (examples/m03_server.py, examples/m04_server.py) that converged on two tools (search_notes, create_note), a resource template (notes://{note_id}), a static resource (notes://index), and a prompt (summarise_topic). This module turns that prototype into a proper package with configuration, clean error handling, long-running work, and tests, so Module 6 can build a host on top of something solid.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.