Replace text inside one adventure page
imagine_replace_in_adventure_pageSurgical find-and-replace inside one adventure page's content. Every byte outside the matched ranges is preserved exactly, so this is the safe primitive for terminology passes (e.g. renaming a monster across a page) where imagine_update_adventure_page's whole-body replace would risk dropping formatting whitespace the LLM can't see in JSON. find matches literally (no regex). All occurrences are replaced in a single pass. Optional expectedOccurrences is a staleness guard — when set, a count mismatch returns 409 with no save instead of silently doing a partial edit. Returns { adventurePage, occurrences }.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>",
"find": "<find>",
"replace": "<replace>"
},
"name": "imagine_replace_in_adventure_page"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Mongo `_id` of the adventure page. | |
| find | Yes | Literal substring to replace inside the page's `content`. Match is literal (no regex); metacharacters are treated as ordinary characters. | |
| replace | Yes | Substring to put in place of every occurrence of `find`. May be empty to delete the matched text. | |
| expectedOccurrences | No | Optional staleness guard. When set, the live page MUST contain exactly this many occurrences of `find` or the call fails with 409 and no save lands. Pre-count by fetching the page first if you want this protection. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||