クライアントの境界を尊重する
ホストが許可した範囲内にとどまります。
「クライアントの境界を尊重する」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. ✅
よくある質問
「クライアントの境界を尊重する」レッスンは無料ですか?
はい。「クライアントの境界を尊重する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「クライアントの境界を尊重する」で何を学びますか?
ホストが許可した範囲内にとどまります。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「クライアントの境界を尊重する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Rootsがサーバーに伝えること
- クライアントのRootsをリクエストする
- 機能をネゴシエーションする
- クライアントの境界を尊重する