Skip to main content
Glama

Edit a theme file

edit_theme_file

Perform targeted find/replace edits in a WordPress theme file while leaving other content unchanged. Fails loudly if a match isn't found, avoiding silent errors.

Instructions

Make targeted find/replace edits inside a theme file, leaving the rest untouched. Safer than write_theme_file for changing one function or block of markup. An edit that matches nothing fails loudly rather than silently writing nothing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath relative to the theme root.
editsYesEdits applied in order.
themeNoTheme stylesheet or draft id.
site_idNoWhich configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids.
allow_live_themeNoPermit editing the live active theme directly. Use a draft instead.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.0.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / edits / items / additionalProperties
      Removed value: -false
  2. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

The annotations already signal a non-read-only, non-idempotent mutation. The description adds useful behavioral context beyond that: edits are surgical, safer than a full write, and a no-match edit fails loudly. This is meaningful and does not contradict the annotations.

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?

Three tight sentences: one states what it does, one gives the key comparison with the sibling alternative, and one discloses an important failure behavior. There is no fluff and the most important distinguishing information is front-loaded.

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?

The description covers the essential context for safe use: targeted edits, comparison to write_theme_file, and loud failure on no match. The schema fills in the remaining operational details like path, theme selection, and live-theme protection. Some minor context such as drafts or ordering is handled by the schema and sibling tools, not a critical gap.

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?

The input schema has 100% description coverage for all parameters, so the schema carries the semantic weight. The tool description adds general context about targeted find/replace and failure behavior, but it does not need to add per-parameter meaning since the schema already documents find, replace, all, regex, required, theme, site_id, and allow_live_theme in detail.

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?

The description states a specific verb and resource: 'Make targeted find/replace edits inside a theme file'. It also distinguishes itself from write_theme_file by emphasizing targeted edits and leaving the rest untouched, so an agent can immediately tell this from siblings.

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?

It explicitly names write_theme_file as the alternative and gives the deciding condition: 'Safer than write_theme_file for changing one function or block of markup'. This gives clear when-to-use guidance rather than leaving it to inference.

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