0Pricing
MCP Academy · Aula

Proteger ações destrutivas

Exija confirmação antes de operações irreversíveis.

Proteger ações destrutivas é uma aula grátis de MCP Academy no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MCP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MCP Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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. ✅

Perguntas Frequentes

A aula “Proteger ações destrutivas” é grátis?

Sim — o texto completo de “Proteger ações destrutivas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MCP Academy, atualize para CoddyKit PRO. O curso de MCP Academy inclui 4 aulas no total.

O que vou aprender em “Proteger ações destrutivas”?

Exija confirmação antes de operações irreversíveis. Você pratica MCP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar MCP Academy?

Nenhuma experiência prévia é necessária. MCP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Proteger ações destrutivas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de MCP Academy?

Sim. Cada aula de MCP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Ameaças exclusivas do MCP
  2. Acesso às ferramentas com menor privilégio
  3. Validar e higienizar tudo
  4. Proteger ações destrutivas
← Voltar para MCP Academy