حماية الإجراءات المدمّرة
اطلبوا التأكيد قبل تنفيذ العمليات غير القابلة للعكس.
حماية الإجراءات المدمّرة درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MCP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MCP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Some Actions Cannot Be Undone
Deleting records, sending emails, charging cards, and pushing code are irreversible operations. These deserve more caution than a harmless read. ⚠️
Reversibility Is the Test
Ask one question of each tool: can I easily undo this? If the answer is no, treat it as high risk and wrap it in extra safeguards before it can run.
Keep a Human in the Loop
For risky actions, pause and ask a person to approve. Human-in-the-loop approval means an injected instruction cannot quietly trigger real damage.
Confirm Before You Commit
A good pattern is to preview the change and require an explicit confirm flag. This tool refuses to act until the caller has clearly opted in.
@mcp.tool()
def delete_user(id: int, confirm: bool = False) -> str:
if not confirm:
return "Set confirm=true to delete."
return remove(id)Show What Will Happen
Before a destructive call, return a clear summary of the exact effect, like which rows vanish. A precise preview lets the approver catch a mistake in time.
Prefer Soft Over Hard
When you can, make actions recoverable: a soft delete that marks a row instead of erasing it lets you reverse a bad call without losing the data.
Make Repeats Safe
Design destructive tools to be idempotent where possible, so calling delete twice does no extra harm. Safe repeats reduce the cost of a confused retry.
Limit Scope and Volume
Cap how much one call can affect. A delete tool that can only remove a single id by id is far safer than one that can wipe a table in one shot.
Use the Sampling Approval Flow
MCP lets a server ask the host to confirm with the user before acting. Routing risky steps through user approval keeps the person in control of the outcome.
Log Every Sensitive Action
Record who triggered each destructive call, with what arguments and when. A clear audit trail lets you detect abuse and recover when something goes wrong.
Default to Caution
When you are unsure whether an action is safe, treat it as if it is not. Defaulting to asking first costs a moment and prevents irreversible mistakes.
Quick Check
Which approach best guards an irreversible delete?
Recap
Treat irreversible actions specially: require confirmation, preview effects, prefer soft deletes, limit scope, and log everything. Default to caution. ✅
الأسئلة الشائعة
هل درس «حماية الإجراءات المدمّرة» مجاني؟
نعم — نص درس «حماية الإجراءات المدمّرة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التهديدات الفريدة في MCP
- الوصول إلى الأدوات بأقل الصلاحيات
- التحقق من كل شيء وتنقيته
- حماية الإجراءات المدمّرة