0Pricing
MCP Academy · درس

احترام حدود العميل

التزموا بالنطاق الذي يسمح به المضيف.

احترام حدود العميل درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.

ماذا ستتعلم في «احترام حدود العميل»؟

التزموا بالنطاق الذي يسمح به المضيف. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟

لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «احترام حدود العميل»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟

نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ما الذي تخبر به Roots الخادم؟
  2. طلب Roots الخاصة بالعميل
  3. التفاوض على القدرات
  4. احترام حدود العميل
← العودة إلى MCP Academy