Skip to main content
Glama

mcp_search_replace

Search and replace a string in text columns across a WordPress site's prefixed tables; use the default dry run to count matches before writing changes.

Instructions

Search and replace a string in every text column of the site's tables (current table prefix only). Plain SQL REPLACE: it is NOT serialization-safe, so a replacement of different length corrupts serialized PHP values (options, postmeta, widgets). Both strings pass through sanitize_text_field on the server (tags and line breaks are stripped). total_changes and tables count matching rows per column, not 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": {
      "site": "<site>",
      "search": "<search>",
      "replace": "<replace>"
    },
    "name": "mcp_search_replace"
  }
}

Input Schema

NameRequiredDescriptionDefault
siteYesSite id (see list_sites)
searchYesString to search for
tablesNoFull table names to limit the run to (must start with the table prefix; empty or omitted = all prefixed tables)
dry_runNoOnly count matches without writing (default true)
replaceYesReplacement string

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv3.14.0
    • changedInput schema / properties / dry_run / description
      Previous value: -"Preview without applying"New value: +"Only count matches without writing (default true)"
    • changedInput schema / properties / tables / description
      Previous value: -"Specific tables (empty = all)"New value: +"Full table names to limit the run to (must start with the table prefix; empty or omitted = all prefixed tables)"
  2. Changed2 schema fields changedv3.4.0
    • addedInput schema / properties / site
      Added value: +{
      +  "description": "Site id (see list_sites)",
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "search",
      -  "replace"
      -]New value: +[
      +  "site",
      +  "search",
      +  "replace"
      +]
  3. First observedv2.0.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does so well: it discloses the underlying SQL REPLACE semantics, that different-length replacements corrupt serialized PHP values, that both inputs are passed through sanitize_text_field (stripping tags and line breaks), and that counts are per-row-per-column rather than per-occurrence. Remaining gaps are capability/permission requirements and the absence of any undo path or partial-failure behavior.

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

Conciseness5/5

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

Four dense sentences, front-loaded with what the tool does, then the safety warning, then input mutation, then counting semantics. Every clause carries information an agent would otherwise get wrong; nothing is repeated from the schema.

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?

For a destructive five-parameter write tool with no annotations and no output schema, this is substantially complete on risk and semantics. It falls short on operational context: required capabilities, whether a run is atomic, and how the site parameter interacts with the 'current table prefix only' restriction.

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

Parameters3/5

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

Schema coverage is 100%, so baseline is 3; the schema already documents site, search, replace, tables and dry_run. The description adds genuine meaning beyond the schema for search/replace by revealing server-side sanitize_text_field mutation, but says nothing new about tables scoping or dry_run that the schema does not already state.

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 (search and replace), a specific resource (a string in every text column of the site's tables), and an explicit scope limit (current table prefix only). That scope limit is what separates it from the sibling search tools (mcp_search_elementor, mcp_search_plugins, mcp_search_themes), which scan specific subsystems rather than raw table columns.

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

Usage Guidelines3/5

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

The serialization warning effectively tells the agent one situation to avoid, but it never names an alternative tool for serialized-data replacement (e.g., the media-specific or option-level siblings) and never advises the safe workflow (dry_run first). Usage is implied by the scope statement rather than routed explicitly.

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

Deploy Server

Other Tools