Human-in-the-Loop Approval
Keep the user in control of server-driven prompts.
Human-in-the-Loop Approval is a free MCP Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why a Human Belongs Here
A server triggering model calls is powerful and risky. So MCP says there should always be a human able to deny a sampling request.
The Client Is the Gatekeeper
The client sits between your server and the model. It can pause every sampling request and ask the user before anything runs.
Review the Request First
Good clients show the user the prompt your server wants to send, so nothing reaches the model without a look.
Let Users Edit the Prompt
Approval is not just yes or no. A user may edit the prompt before it goes out, refining what your server asked for.
Review the Response Too
After the model replies, the client can show the generated text for approval before handing it back to your server.
The Full Loop
The flow is: server asks, user approves, model runs, user reviews, result returns. Two checkpoints wrap the model call.
A Denial Is an Error
If the user says no, the client returns an error like rejected sampling request — not a normal empty result.
{ "error": { "code": -1,
"message": "User rejected sampling request" } }Handle Rejection in Your Tool
Wrap the call and catch failures. On a rejection, return a clear message instead of crashing or hanging the tool.
try:
r = await ctx.session.create_message(...)
except Exception:
return "Sampling was declined."Do Not Assume Approval
Never design a tool that breaks if sampling is refused. Treat approval as optional and always have a fallback path.
The Protocol Only Recommends
MCP does not force a specific UI; the human-in-the-loop is a strong SHOULD. Clients choose how to present approval.
Trust by Design
This review step is the heart of safe sampling: it keeps the user in control of what their model is asked to do.
Quick Check
Last check — the safety model of sampling.
Recap
Safe sampling keeps a human in control: the client can review and edit prompts, approve responses, and deny requests — so build for rejection. ✅
Frequently asked questions
Is the “Human-in-the-Loop Approval” lesson free?
Yes — the full text of “Human-in-the-Loop Approval” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Human-in-the-Loop Approval”?
Keep the user in control of server-driven prompts. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MCP Academy?
No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Human-in-the-Loop Approval” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MCP Academy lesson?
Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Sampling Unlocks
- Request a Completion from the Host
- Shape Messages & Preferences
- Human-in-the-Loop Approval