Roots and Elicitation — Scoping and Mid-Flight User Input

Hard-coded paths break the moment a user opens a different project. Pre-filled tool arguments break when the user under-specifies. Roots scope the server to a user-controlled set of URIs; elicitation pauses mid-tool-call to ask the user for structured input via a form or URL. Two client primitives, two fixes for common MCP failure modes. SEP-1036 (URL-mode elicitation, 2025-11-25) is experimental through H1 2026 — check SDK versions before depending on it.

Build 45 min Python (stdlib, roots + elicitation demo)

Prerequisites: Phase 13 · 07 (MCP server)

#Learning Objectives

  • Declare roots and respond to notifications/roots/list_changed.
  • Restrict server file operations to URIs inside the declared root set.
  • Use elicitation/create to ask the user for a confirmation or structured input mid-tool-call.
  • Choose between form-mode and URL-mode elicitation (the latter is experimental; drift-risk noted).
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.