patch_kb_doc
Performs string replacements in a knowledge-base document — same idea as Cursor StrReplace for files. USE THIS instead of update_kb_doc when the document body is large and you only need to change a specific section. Workflow: get_kb_doc → copy the span into old_string (include enough surrounding context to make it unique) → new_string is the replacement → this tool patches content (or name) and PATCHes the KB doc. Prefer an exact copy from get_kb_doc; minor whitespace/line-ending drift is tolerated as a fallback. Prefer this over rewriting the entire content field. Only use replace_all=true when you intentionally want every occurrence changed.
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": {
"agentId": "<agentId>",
"docId": "<docId>",
"old_string": "<old_string>",
"new_string": "<new_string>"
},
"name": "patch_kb_doc"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | The KB document ID | |
| field | No | Which KB field to patch. Default content (document body). | |
| agentId | Yes | The agent ID | |
| new_string | Yes | Replacement text for the matched span. Use an empty string to delete the matched text. | |
| old_string | Yes | Text to find in the KB field. Prefer an exact copy from get_kb_doc; minor whitespace/line-ending drift is tolerated. Include surrounding context so the match is unique unless replace_all is true. | |
| replace_all | No | If false (default), fails when old_string matches more than once. If true, replaces every occurrence. |