Respect Client Boundaries
Stay inside the scope the host permits.
Respect Client Boundaries 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.
Knowing Isn't Enough
You can fetch roots and read capabilities, but the real job is honoring them. A trustworthy server stays inside the lines the host drew for it. 🚧
Stay Inside the Roots
Before touching any file, confirm its path sits within one of the client's roots. If it does not, refuse rather than reaching outside the allowed area.
Resolve Paths First
A sneaky path like ../../etc can escape a root. Always resolve to an absolute, normalized path before comparing it against your allowed folders.
from pathlib import Path
real = Path(p).resolve()Check Containment Safely
Test that the resolved path is relative to a root. The pathlib helper raises if it escapes, giving you a clean yes-or-no on whether to proceed.
real.relative_to(root_path)Don't Use Missing Features
If the client never declared a capability, do not call it. Respecting boundaries means trusting the negotiation, not poking at features that were never offered.
Degrade Gracefully
When roots are empty or unsupported, do not guess at the filesystem. Narrow what your tool does and tell the user why, instead of grabbing arbitrary paths.
Least Privilege by Default
Roots set an outer limit, but you can be stricter. Ask only for what a task truly needs, the spirit of least privilege, and leave the rest untouched.
Boundaries Aren't Just Folders
Respect goes beyond paths. Honor the host's pace and limits too, so you never flood it with calls or ignore a cancellation the user asked for.
Re-validate After Changes
When a roots list_changed notice arrives, re-check any cached paths. A folder allowed a minute ago may now be outside the user's current scope.
Fail Loud, Not Wide
If a request points outside the roots, return a clear error the model can read. A polite refusal beats silently doing something the user never sanctioned.
Why This Earns Trust
Servers that respect boundaries are the ones users keep installed. Good scoping turns a powerful tool into a safe one people are happy to grant access. 💛
Quick Check
One request targets a path outside every declared root. What should your server do?
Recap: Honoring the Limits
You resolve paths, confirm they sit inside a root, skip undeclared features, degrade gracefully, and refuse out-of-scope work. That is what makes a server trustworthy. ✅
Frequently asked questions
Is the “Respect Client Boundaries” lesson free?
Yes — the full text of “Respect Client Boundaries” 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 “Respect Client Boundaries”?
Stay inside the scope the host permits. 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 “Respect Client Boundaries” 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 Roots Tell a Server
- Request the Client's Roots
- Negotiating Capabilities
- Respect Client Boundaries