Skip to main content
Glama

wp_set_theme_file

Write a WordPress theme file with safety checks: dry-run preview, automatic revert on fatal errors, and read-back verification to prevent site downtime.

Instructions

Write one theme file. THIS EXECUTES CODE ON THE SITE - the highest-risk tool here.

A theme file is PHP. A syntax error does not break a layout, it takes the SITE down. Mitigations, in order:

  • the write goes through WordPress core's own theme editor, which makes a loopback request after writing and AUTOMATICALLY REVERTS the file if the site fatals;

  • the result carries previous, the exact prior contents, so you can revert with a second call - KEEP IT;

  • the write is verified by re-reading the file, and a mismatch is an error, never a success;

  • path traversal, absolute paths, and non-code extensions are refused, and a non-active theme needs allow_other_theme=true (editing a parent theme is how changes get lost on the next update - prefer the child theme). DEFAULTS TO dry_run=true, which writes nothing and returns the file's CURRENT contents next to what you propose. Read it and diff before setting dry_run=false. Prod writes require allow_prod=true. CREATING files is not supported - core's self-reverting editor only edits files the theme already has; add new files by deploy/SFTP first. allow_create is accepted but cannot make creation work.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
themeNo
dry_runNo
installYes
contentsYes
allow_prodNo
allow_createNo
allow_other_themeNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.4.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations provided, the description carries the full transparency burden. It details the write mechanism (core editor), the automatic revert on fatal errors, the verification via re-reading, the return of previous contents, and the limitation on creation. These are critical behavioral characteristics that are fully disclosed.

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 relatively long but every sentence conveys essential safety or usage information. The bullet-point format improves readability. It could potentially be trimmed, but given the high risk and number of caveats, the detail is justified and not redundant.

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 most important contextual aspects: risk, safety nets, defaults, constraints (no creation, prod guard), and a comparison to the read sibling. It does not specify the exact success/error response format, but it does mention what dry_run returns, which is sufficient for an agent to anticipate outcomes.

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?

Although the schema has no field descriptions, the tool description explains several parameters: dry_run, allow_prod, allow_create, and allow_other_theme. 'file' and 'contents' are self-explanatory, and 'theme' is implicitly covered by the allow_other_theme note. However, 'install' is not explicitly described, leaving a minor gap in full parameter understanding.

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's purpose: 'Write one theme file' and explicitly contrasts it with the reading sibling wp_get_theme_file. It also highlights the high-risk nature of the operation, leaving no ambiguity about what the tool does.

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?

The description provides concrete usage guidance: defaults to dry_run=true, advises reading before writing, explains the allow_prod and allow_other_theme flags, and explicitly states that file creation is not supported, directing the user to deploy/SFTP instead. This is actionable and prevents misuse.

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

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/ad02/wp-ops-mcp'

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