Skip to main content
Glama

patch_kb_doc

Destructive

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

NameRequiredDescriptionDefault
docIdYesThe KB document ID
fieldNoWhich KB field to patch. Default content (document body).
agentIdYesThe agent ID
new_stringYesReplacement text for the matched span. Use an empty string to delete the matched text.
old_stringYesText 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_allNoIf false (default), fails when old_string matches more than once. If true, replaces every occurrence.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and idempotentHint=false, so the mutation profile is known; the description adds that the tool PATCHes the KB doc, that a non-unique match fails, and that whitespace/line-ending drift is tolerated as a fallback. It does not spell out what is lost on replacement (original text is overwritten) or what the response contains, but the key behavioral surprises are covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and the sibling routing decision, followed by a compact workflow line. Some redundancy: 'Prefer this over rewriting the entire content field' repeats the earlier reasoning about large documents, and the old_string uniqueness guidance duplicates the schema text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description could say more about what comes back after a successful patch, and it is silent on the destructive nature of overwriting text. Still, between the workflow, failure-on-ambiguity note, and field targeting, an agent has enough to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description goes slightly beyond by telling the agent to copy old_string from get_kb_doc and to include enough surrounding context for uniqueness. It also confirms the field parameter can target name as well as content. Most of this is echoed in the schema, so it isn't a full 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (string replacement in a knowledge-base document) and anchors it with a well-known analogue (Cursor StrReplace). Explicitly distinguishes itself from the sibling update_kb_doc by scope and document size, so the agent can pick between them without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use ('USE THIS instead of update_kb_doc when the document body is large'), when-to-use-the-other ('Prefer this over rewriting the entire content field'), and a full call sequence (get_kb_doc → copy span → build new_string). The replace_all caveat ('only when you intentionally want every occurrence changed') is a clear conditional, not just a restatement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources