update-page
Modify an existing wiki page by replacing its content, appending or prepending text, or rewriting only a matched passage. Optionally target a single section and reject the write if the page changed since the given revision.
Instructions
Writes to an existing wiki page and returns the new revision ID. Fails if the page does not exist; for new pages, use create-page. operation says what the write does and section says where: omit section to act on the whole page, or set it to confine the write to one section. For changing part of a page, use operation='find-replace', which carries only the text being rewritten, so nothing outside find can be lost and the rest of the page never has to travel to or from the caller; a find that matches nothing, or more than one place, is refused without writing, which also makes it safe to resend a call whose result never arrived. For replacing a target outright, use operation='replace', whose source must carry every byte meant to survive; it is refused when source would shorten a target too large for one read to return whole, since the rest was never seen. With section set it also takes out every subsection nested under that section, is refused when source would drop them, and needs latestId to say which revision the section number was read from. operation='append' and 'prepend' add a delta: a new section at the end of the page is an append whose source begins with the heading, and with section set a prepend inserts one immediately above that section. Pass latestId (reported as latestRevisionId by any get-page read that returns wikitext) for edit-conflict detection: the write is rejected rather than silently clobbering a concurrent change. Each call is a separate revision, and resending an append or prepend whose result never arrived adds the delta a second time.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bot | No | Marks the edit as a bot edit, which Special:RecentChanges hides by default. Takes effect only when the authenticated account has the `bot` right (granted by the bot group, or by the high-volume grant on a bot password or OAuth consumer); without it the edit saves unflagged and the response reports botMarked: false. Use when performing bulk or automated edit runs, or when the user requests it. | |
| find | No | The existing wikitext to rewrite, matched in full and exactly, whitespace and template markup included. Required when operation is 'find-replace'. A find that matches nothing, or more than one place, is refused without writing: extend it with the text around it to name one occurrence. | |
| mode | No | Deprecated older spelling of operation='append' and operation='prepend'. Send operation instead. | |
| wiki | No | Wiki to target, as a key from the mcp://wikis/ resources (e.g. en.wikipedia.org), or the full mcp://wikis/ URI. Omit to use the default wiki. | |
| title | Yes | Wiki page title | |
| source | No | The content to write, in the existing page's content model. Required for every operation except find-replace, and refused for that one. An appended source that opens a new section must begin on its own line, as in "\n\n== History ==\n\nBody."; without the leading newline the heading runs on from the last line of the page and is not recognised as a heading. | |
| comment | No | Summary of the edit | |
| section | No | Section number (0 = lead; 1..N = heading sections), from the section list get-page reports. Confines the write to that section: omit it to act on the whole page. A replace also takes out every subsection nested under the section; see removeSubsections. | |
| latestId | No | Base revision ID for edit-conflict detection; any get-page read that returns wikitext reports it as latestRevisionId. Required when section is set, because the wiki resolves a section number against this revision rather than against whichever is current. If omitted on a write that is not scoped to a section, the update is applied without conflict detection. | |
| operation | No | What the write does to the target: 'replace' overwrites it with source, 'append' and 'prepend' add source to it, and 'find-replace' rewrites only the text find names and leaves the rest of the target byte for byte. With section=N, 'append' writes at the end of that section and 'prepend' immediately above that section's heading, which inserts a new section before an existing one. Defaults to 'replace'. | |
| replaceWith | No | What find becomes. Required when operation is 'find-replace'; an empty string deletes the text find matched. | |
| removeSubsections | No | Confirms that replacing this section is meant to remove the subsections nested under it. Required only when section is set and source contains fewer subsection headings than the section currently has. | |
| removeUnreadContent | No | Confirms that replacing content larger than a single read returns is meant to discard the part that was never returned. Required only when the target holds more bytes than one response carries and source holds fewer. |