CourseModel Context Protocol · Module 6: Clients and Hosts · part 34 of 83
Part 34 · Module 6: Clients and Hosts

Topic 1: Module 6 at a glance, and the setup

7 min read·22 Sept 2026

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

  • A host (notes_assistant/host.py) that connects to MCP servers over stdio or Streamable HTTP, converts their tools to the Chat Completions format, and runs a bounded agent loop.
  • An agent loop you can test without an API key, with iteration limits, repeated-call detection, and a no-progress extension you wrote yourself.
  • Measured numbers for parallel versus sequential tool calls, and timeouts that stop a slow server from freezing the conversation.
  • A two-server host (notes plus a lab calendar) where namespacing prevents a real tool-name collision, plus a tool-search meta-tool that cuts tool definitions sent per round by about 86 percent in a 37-tool setup.
  • Local rules that decide what runs, what asks, and what never runs, a consent prompt that shows the exact file a write will create, and measured prompt counts showing how a read-only allowlist cuts approval fatigue.
  • A clear picture of what a host sees when a server is slow, returns an error, or dies in the middle of a session, and how to recover.

Prerequisites: Modules 1 to 5. You need the notes server from Module 5 (notes_assistant/server.py with build_server(store)), the NoteStore from store.py, and the chat() helper from llm.py. Comfort with async/await and anyio task groups helps.

Where we are: Module 5 built the server side properly: a tested build_server(store) that runs over stdio and HTTP. So far we have only poked it with the Inspector and small client scripts. This module builds the other half: the host that puts a model, a person, and one or more servers in the same room and stays in charge of all three.

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.