Ask for confirmation and resume¶
Start with the registry tutorial. A handler can suspend by returning an owned input request:
input, err := mcp.NewFormInput(
"Confirm the prepared change",
json.RawMessage(`{"type":"object","properties":{"confirmed":{"type":"boolean"}},"required":["confirmed"],"additionalProperties":false}`),
json.RawMessage(`{"intent":"change-123"}`),
)
if err != nil {
return mcp.Outcome{}, err
}
return mcp.AwaitInput(input), nil
On the next invocation, use invocation.Resume() to distinguish a verified answer from the initial request. Check
resume.Action() and the explicit confirmed boolean. Accept alone does not authorize the change. Use the intent
key in resume.State() to identify prepared application work, and store the completed result durably under that key.
When resume.RecoveryOnly() is true, recover the prior outcome and return Finish; do not start another interaction.
The host opts into the modes it can actually present:
After registry.Invoke, inspect reply.Input(). Present pending.Request().Form() to the user, construct their explicit
response with NewInputResponse, then call the same operation with the original arguments and
WithResume(pending.Continuation(), response). Continue declaring supported modes if another prompt may follow.
Treat the token as private. Do not manufacture acceptance or automatically resubmit side effects on errors.
The executable ExampleRegistry_Invoke_confirmation in interaction_example_test.go shows the whole exchange.
Its in-memory intent map demonstrates the application responsibility; production applications need their own durable,
concurrency-safe store. Read the interaction reference for replay, budgets and expiry.