Skip to main content
Glama

wp_set_custom_code

Destructive

Inject site-wide CSS and/or JavaScript on every page. ONE snippet carries both: put CSS in a block and JS in a block in the same code body. Use this for anything the brand kit's design tokens cannot express — backdrop-filter, clip-path, layered shadows, @keyframes animation, scroll/sticky behaviour, analytics and third-party embeds. name is the IDEMPOTENCY KEY: re-pushing the same name UPDATES that snippet, so a re-run cannot stack duplicates that all inject at once. CHANGES EVERY PAGE — pass confirm=true. READ rendered IN THE RESPONSE, NOT THE STATUS CODE: the connector fetches the front page and reports whether the code actually reached the HTML, so a snippet that saved but never rendered comes back rendered=false with a hint instead of looking like success. The XeoRank Connector injects these itself on wp_head / wp_body_open / wp_footer, so it needs NO Elementor Pro and works on any theme — but it also means the snippets live in XeoRank, not in Elementor's Custom Code UI. Requires Connector v0.9.2+. CHOOSING THE RIGHT HOME: this renders on the frontend, but CSS that must show inside the Elementor editor CANVAS belongs in wp_set_brand_kit(custom_css); CSS scoped to one element belongs in wp_patch_page(style.custom_css). Prefer brand-kit TOKENS over CSS whenever a token can express it — tokens stay editable in the UI, CSS does not.

Input Schema

NameRequiredDescriptionDefault
codeYesRaw markup to inject. May contain <style> and/or <script> blocks. Not escaped — send it exactly as it should appear in the page.
nameYesSnippet name, e.g. 'XeoRank — global CSS'. Also the idempotency key: re-using it updates that snippet in place.
statusNo'publish' (default, live) or 'draft' (saved, not injected)
verifyNoCheck the code really rendered on the front page. Default true — leave it on.
confirmNoMust be true to apply — without a narrower `conditions`, this injects on every page
site_idYesWordPress site id (from list_wordpress_sites)
locationNoWhere to inject: 'head' (default; critical CSS, meta, tracking), 'body_start', or 'body_end' (non-critical JS, avoids render-blocking).
priorityNo1-10, default 10 (rejected with an error outside that range, never silently clamped). LOWER runs earlier when several snippets share a location.
conditionsNoElementor display conditions. Defaults to ['include/general'] (entire site) — an empty set would inject nowhere. When this site falls back to XeoRank's own injector (injected_by:'xeorank-connector' in the response) only these shapes are actually enforced: 'include/general', 'include/singular/front_page', 'include/singular/page', 'include/singular/page/<id>', 'include/singular/post', 'include/singular/post/<id>'. Any other shape (archive/taxonomy/exclude conditions) matches nothing on the fallback path — use one of the shapes above to scope a snippet to one page/post there.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Far exceeds the annotations: it discloses that confirm=true is mandatory because the change hits every page, that the write is idempotent-by-name (re-pushing the same name updates in place), that success must be read from `rendered` rather than the status code, that verification fetches the front page, that the connector injects on wp_head/wp_body_open/wp_footer with no Elementor Pro dependency, and that snippets live in XeoRank rather than Elementor's Custom Code UI, with a v0.9.2+ requirement. This is exactly the operational context annotations cannot carry. Minor tension: the description calls `name` an 'IDEMPOTENCY KEY' while idempotentHint=false, but the described behavior is update-in-place on repeated calls, so this reads as a conservative annotation rather than a true contradiction.

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 the core action and the one-snippet convention, then interleaved with routing and verification guidance. Dense and mostly earned, though the CHOOSING THE RIGHT HOME block and the connector/version sentences make it longer than a strictly minimal definition — justified by tool complexity, but not maximally tight.

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

Completeness5/5

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

For a destructive, 9-parameter, no-output-schema mutation, the description covers the gaps that matter: the mandatory confirm flag, how to interpret the response (`rendered` vs status code), the fallback-path limits on `conditions`, and environment prerequisites. Nothing an agent needs to invoke it correctly is missing.

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, but the description adds real meaning: `name` as the update-in-place key, `confirm=true` as the per-page blast-radius gate, and the note that without narrower `conditions` the snippet injects everywhere. It does not restate the injection-location or priority semantics beyond the schema, keeping it just above baseline.

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?

Names a specific verb+resource (inject site-wide CSS/JS) and immediately fixes the scope (every page) and the single-snippet convention (CSS in <style>, JS in <script> in the same `code` body). It actively distinguishes itself from siblings by name: wp_set_brand_kit(custom_css) for editor canvas, wp_patch_page(style.custom_css) for element-scoped CSS.

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?

Explicit when-to-use ('anything the brand kit's design tokens cannot express', with a concrete list of examples, plus analytics/third-party embeds) and explicit when-not (prefer brand-kit tokens; use brand kit or page patching elsewhere). The CHOOSING THE RIGHT HOME sentence routes the agent among three sibling tools with the discriminating condition for each.

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