Skip to main content
By default, edit_document changes the session document. In suggestion mode, the Vespper SDK proposes the edits instead. The document stays unchanged, and your code receives each edit as a suggestion. Your client shows the suggestions, the user reviews and optionally modifies them, and your API applies only the ones the user accepts.

How it works

  1. Patch the MCP client with suggest: true.
  2. When the agent calls edit_document, the SDK resolves each edit against the session’s current document without applying it, and returns it as a suggestion.
  3. Your client shows each suggestion. The user can modify its HTML, then apply or discard it.
  4. Your API applies the accepted suggestions with applyEdits() or apply_edits().

Enable suggestion mode

Pass suggest when you patch the MCP client:
read_document and search_document work as before. edit_document no longer changes the document: it only locates each edit in the document and returns it as a suggestion. For example, when the agent proposes changing “grew steadily” to “grew 12%” in sample.docx, edit_document returns:
See Suggestion mode in the API reference for every field.

Apply accepted suggestions

Send the accepted suggestions to applyEdits() or apply_edits() as old/new pairs. A suggestion sent back unchanged applies exactly the proposed edit. If the user modified a suggestion, send their HTML as new. Edits apply in parallel, and each outcome’s position is the edit’s index in the list you passed. applyEdits() accepts any session ID, so the request that applies suggestions doesn’t have to be the one that ran the agent. This example proposes one edit to sample.docx, then applies it. In your app, the agent makes the edit_document call, and the user reviews the suggestion before your API applies it.

Stream suggestions

In suggestion mode, a patched edit_document call doesn’t change the document. It only locates each pair in the session document and returns early with the suggestion, so it’s safe to call for each pair while the model is still writing. To show suggestions as they stream, parse the edit_document arguments as they arrive. Call the patched tool with each old/new pair once it’s complete, and send the suggestion to the client. The ONLYOFFICE add-in shows the complete wiring of suggestions to a UI layer.