Replace Text in a Post
Changes one passage of text inside a post or page, leaving every other byte untouched. Use this whenever you are changing part of the text: it is far cheaper than rewriting the whole post, and it cannot lose formatting, shortcodes or block markup the way a full rewrite can. Use mosmcp/post-update instead only when you are deliberately replacing the entire content with new text you already have in full. The text must appear exactly once, or the change is refused and the alternatives are listed, so nothing is ever changed in the wrong place.
Also known as: find and replace, change wording, edit text, reword, update copy, change a phrase.
| Property | Value |
|---|---|
| Ability slug | mosmcp/content-replace-in-post |
| Wire tool name | mosmcp__content-replace-in-post |
| Category | Content Editing (mosmcp-content-editing) |
| Plan | Free |
Required access
| Requirement | Value |
|---|---|
| Capability | edit_post (checked against the specific post) |
| Minimum default role | Contributor |
| Annotations | readOnly: false · destructive: false · idempotent: false · openWorld: false |
Input schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| id | integer (min 1) | Yes | — | The ID of the post or page to edit. |
| field | string (one of post_content, post_excerpt, post_title) |
post_content |
Which field to edit. | |
| find_text | string | Yes | — | The existing wording to replace. Get this from mosmcp/content-find-in-posts rather than from the visible page, so it matches what is stored. |
| replace_with | string | Yes | — | The new wording. Pass an empty string to delete the found text. |
| replace_all | boolean | false |
Change every occurrence instead of requiring the text to appear exactly once. Leave false unless every occurrence really should change. | |
| whole_word | boolean | false |
Only match the text when it stands as a whole word, so "cat" does not match inside "catalogue". |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| target | string | Yes | What was edited, for example "post 12 post_content". |
| changed | boolean | Yes | |
| occurrences | integer | Yes | How many occurrences were replaced. |
| match_mode | string | How the text was matched. Anything other than "exact" means the stored wording differed from what was asked for, so the result is worth checking. | |
| length_before | integer | ||
| length_after | integer | ||
| stored_verbatim | boolean | False when the site altered the text on the way in, which means the stored value now differs from what was sent. | |
| notes | string[] |
Example
Sample prompt
On the Shipping Policy page, change '$50' to '$75' in the free shipping sentence.
Example request (json)
{
"jsonrpc": "2.0",
"id": 155,
"method": "tools/call",
"params": {
"name": "mosmcp__content-replace-in-post",
"arguments": {
"input": {
"id": 14,
"find_text": "Free shipping on orders over $50",
"replace_with": "Free shipping on orders over $75"
}
}
}
}Example response (json)
{
"jsonrpc": "2.0",
"id": 155,
"result": {
"isError": false,
"structuredContent": {
"target": "post 14 post_content",
"changed": true,
"occurrences": 1,
"match_mode": "exact",
"length_before": 2310,
"length_after": 2310,
"stored_verbatim": true,
"notes": []
}
}
}
Edge cases / errors
- Text appears more than once → mosmcp_multiple_matches with the count and positions, unless replace_all is true.
- Text not found → mosmcp_text_not_found with the closest stored passages; identical replacement → mosmcp_no_change.
- Change would break block markup in post_content → mosmcp_blocks_would_break; nothing is written.
- Missing post → mosmcp_post_not_found; field outside post_content/post_excerpt/post_title → mosmcp_field_not_editable.
| << Previous | Next >> |
|---|---|
| Replace Text in a Custom Field | Replace Text in a Setting |
For more information about the Secure MCP Server for WordPress plugin, explore the following resources:
Product Overview | Pricing | Try for Free | Documentation
If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.