---
title: "Selected Paragraph Undo"
method: POST
path: "/api/mcp/paragraph_undo"
tags: ["mcp"]
---

# Selected Paragraph Undo

`POST /api/mcp/paragraph_undo`

## Request

- Base URL: `https://writer.swapp1990.org` (the document declares no server; this is the origin it was published from)
- URL: `https://writer.swapp1990.org/api/mcp/paragraph_undo`
- Auth: none declared

Restore specific paragraphs to a client-provided snapshot.

Pure DB write — no LLM call. The client snapshots the
pre-apply paragraphs before calling selected_paragraph_apply_plan; if
the user dislikes the result, the snapshot comes back here and we write
it into the chapter's latest revision in-place. Costs 0 credits (free
undo).

## Request body

- SelectedParagraphUndoInput: Restore specific paragraphs in-place to a client-provided snapshot. Used by the reader's "Undo" affordance after selected-paragraph apply: the client snapshots the pre-apply paragraphs before applying, then if the user dislikes the result it sends them back here. Pure DB write - no LLM, no decompose. Costs 0 credits. When the lengths match, `restored_paragraphs` is parallel to `paragraph_indices`; entry i replaces the chapter's paragraph at index paragraph_indices[i]. When the lengths differ, `paragraph_indices` must be one contiguous current range, and that whole range is spliced out and replaced with `restored_paragraphs`. This lets undo collapse a 1->3 expansion back to the original single paragraph without duplicating the following prose. Map restore uses only trusted server ledger/event snapshots correlated by range/operation_id. Clients never supply an authoritative map snapshot.
  - `job_id` string, required: The story job ID.
  - `chapter` integer, required: Chapter number containing the paragraphs.
  - `paragraph_indices` integer[], required: 0-based paragraph indices to restore.
  - `restored_paragraphs` string[], required: Pre-apply text for each index, in the same order.
  - `base_revision` integer, nullable: Revision number to restore into. None = latest.
  - `operation_id` string, nullable: Optional operation_id from the apply ledger/event used for stronger map-snapshot correlation. Optional for current clients.

## Response `200`

Successful Response

- GenericToolResponse: Fallback for tools whose payload is still being tightened.
  - `story_url` string, nullable
  - `article_url` string, nullable
  - `job_id` string, nullable
  - `status` string, nullable
  - `is_terminal` boolean, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/swapp1990/apis/writeforyou-mcp-api.md) · [All operations](https://skmtc.dev/swapp1990/apis/writeforyou-mcp-api/llms.txt) · [OpenAPI document](https://skmtc.dev/swapp1990/apis/writeforyou-mcp-api/revisions/ce5e2a89ab4d?raw)
