Prepared writes
Prepare, review, confirm and reconcile writes made inside an MCP App view.
The protocol hooks manage this flow in React, including the proposal key and the confirmation and reconciliation states.
1.Prepare
Validate the proposal on the server before writing. Return the current value, proposed value and a proposal ID or idempotency key. If validation refuses the proposal, render status="refused" and pass the reason to refusedDescription.
2.Review
Show the record and the from and to values using changePreview. ConfirmAction adds a reminder that nothing is saved until the user confirms.
3.Confirm
Run the write when the user presses Confirm. Revalidate the proposal on the server and deduplicate repeated requests using the original key. Show working while the request is in flight and done after the server confirms the write.
After a confirmed write, tell the model what changed using a short summary of information already visible in the view. tellModel caps summaries at 500 characters and uses host model context when text updates are supported. Set fallbackToMessage: true only if the view should post a visible chat message when context updates are unavailable.
import { tellModel } from "@/lib/host"
// Run after confirming the write and updating the view.
void tellModel(app, "Northwind Traders moved to Negotiation.")4.Reconcile
If a timeout or connection loss leaves the outcome uncertain, show status="unknown". Wire onCheckAgain to read the current state or check the original idempotency key. Keep the outcome unknown until you have enough evidence to resolve it. Use the retryable error state only if the server confirms the write did not happen and retrying is safe.
See the Confirm action component for the full props.