Skip to main content
Glama

Edit a theme file

edit_theme_file

Modify specific parts of a WordPress theme file with targeted find/replace edits, leaving the rest untouched. Fails if no match is found to prevent 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.
Behavior4/5

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

Annotations already indicate a mutation (readOnlyHint=false), and the description adds meaningful behavior: 'leaving the rest untouched' asserts a safety property, and 'an edit that matches nothing fails loudly' clarifies error handling. It doesn't cover ambiguous multiple matches, but the schema already documents the required/all flags. Overall it adds useful context beyond 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.

Conciseness4/5

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

The description is concise—three sentences, each adding value: the first states the function, the second gives usage guidance, and the third describes a key behavior. It is front-loaded with the core purpose. No redundant text, but it could be slightly tightened without losing information.

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?

Given the 5 parameters and the nested edits array, the description covers the main usage scenario and distinguishes it from the write_theme_file sibling. It does not explain return values (no output schema), but annotations and schema handle parameter details. The mention of failure behavior and the safety comparison cover most operational context an agent needs.

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 description coverage is 100%, so every parameter is already documented with clear descriptions in the schema. The description does not add extra meaning to the parameters themselves; it only provides a general context. With full schema coverage, a baseline of 3 is appropriate.

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 clearly states the tool performs targeted find/replace edits inside a theme file while leaving the rest untouched. It explicitly distinguishes itself from write_theme_file by positioning itself as safer for single-function or block changes, so an agent immediately knows what it does and how it differs from its closest sibling.

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

Usage Guidelines4/5

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

It provides a clear usage signal: use this instead of write_theme_file when making focused changes. The phrase 'Safer than write_theme_file for changing one function or block of markup' gives a specific condition. It doesn't enumerate exclusions (e.g., when creating a new file or rewriting whole files), but the positive guidance is strong enough for most agents.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alokemajumder/wpxmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server