Security and Trust Between Site and Agent|INEMA.CLUB-PRO

Lesson 3 · 18 min

An action with consequences needs a human: confirmation and consequentialHint

Booking, canceling, paying, deleting. The agent may pick the wrong tool, misread the description, or obey planted text. The WebMCP spec answers with consequentialHint, so the client can require confirmation. In this lesson you add the annotation and your site's own confirmation, and you prove that declining changes nothing.

Start the lesson
Confirmation dialog on a dark screen with two neutral buttons, a person's hand near the mouse, neutral light.

In this lesson you will

  1. 1Misdescribed intent: the spec's finalizeCart case
  2. 2consequentialHint (a signal for the client) and the site's confirmation (your lock)
  3. 3The test that declines and checks that nothing changed
  4. 4The limit: an agent that operates the screen can click the button too

Goal: add consequentialHint and a confirmation with target and effect to every tool that changes something, and prove that declining changes nothing.

01From request to effect, with a person in the middle

Tap each step.

Click each block in the diagram to see what it does.

The annotation is for the client; the confirmation is yours. One doesn't replace the other.

02Confirmation that protects

1. Target and effect

The question says what, whose, and what happens next. "Are you sure?" won't do: the person doesn't know what they're approving.

03The second hole: canceling without asking

Edit cancelar_agendamento in kit/pagina/ferramentas.mjs as in the snippet and run the checker. The finished version is in kit/solucao/aula3/.

Snippet · kit/solucao/aula3/ferramentas.mjs
      annotations: { consequentialHint: true },              // lesson 3: warns that the action has consequences
      execute: util(async ({ codigo }, { signal }) => {
        const ag = agenda.agendamentos().find(a => a.codigo === codigo);
        if (!ag) throw new Error(`agendamento não encontrado: ${codigo}`);
        // the question states the target and the effect in full; aborting the run (signal) counts as "no"
        const ok = await ui.pedirConfirmacao(`Cancelar o agendamento ${ag.codigo} (${ag.id}, ${ag.nome})? A vaga volta para a agenda.`, signal);
        if (!ok) return { cancelado: false, motivo: 'a pessoa recusou na tela' };
        agenda.cancelar(codigo);
        ui.atualizar();
        return { cancelado: true, agendamento: ag };
      })
Terminal · check afterward
cd ~/projetos/formacao-webmcp-seguranca-v72/kit
node scripts/checar.mjs; echo "saída: $?"
Example from the repository
== Chromium 156.0.8078.4 (Playwright) · modo: nativo
ok    buscar_mentorias: só leitura, sem texto de terceiro
ok    ler_avaliacoes: devolve texto de terceiro e está marcada com untrustedContentHint
ok    meus_agendamentos: só leitura, sem texto de terceiro
ok    agendar_mentoria: consequentialHint + confirmação; recusar não mudou nada
ok    cancelar_agendamento: consequentialHint + confirmação; recusar não mudou nada
RESULTADO: 0 falhas
saída: 0

Before the fix, the same line said FALHA cancelar_agendamento: agiu sem pedir confirmação (output from lesson 2).

04Practice

The lock, in the kit and on your page.

E7 · Fix the cancellation

15 min

Put consequentialHint and the confirmation in cancelar_agendamento and run the check afterward block.

Done when: RESULTADO: 0 falhas and saída: 0.

E8 · Break it on purpose

5 min

In agendar_mentoria, replace const ok = await ui.pedirConfirmacao(…) with const ok = true and run the checker. Then undo it.

Done when: FALHA agendar_mentoria: agiu sem pedir confirmação and saída: 1; once undone, RESULTADO: 0 falhas.

E9 · Inventory of your site

20 min

List the tools on your site that change something. Each one gets consequentialHint: true and a question that names the target and the effect.

Done when: grep -c "consequentialHint: true" [your tools file] → the number of tools on your list.

05Lesson quiz

Question 1 of 4

What does the spec say the client can do when it sees consequentialHint?skill

06In three sentences

AnnotationconsequentialHint on every tool that changes something.
ConfirmationFrom the site, with target and effect, one per call; refusing changes nothing.
LimitA button on screen is one the agent also clicks; high value calls for what only the person has.

Going further

Previous lessonNext lesson