Skip to main content
Glama

Manage code snippets

code_snippet

Add PHP, CSS, or JavaScript to WordPress as managed snippets that survive theme updates and remain disabled until activated, with PHP syntax checked before saving.

Instructions

Add PHP, CSS or JavaScript to the site as a managed snippet rather than by editing theme files — so it survives theme updates and can be switched off without touching code. New snippets are always created DISABLED: you activate them in wp-admin after reading the code. PHP snippets are syntax-checked before they are saved, so a parse error is reported rather than fataling the site.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoSnippet id, for get/update/delete.
codeNoThe snippet body. For PHP, omit the opening <?php tag.
titleNoSnippet name, for create/update.
actionYesWhat to do.
confirmNoRequired for delete.
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.
languageNoSnippet language, for create.
locationNoWhere it runs. CSS and JS snippets usually want header or footer.everywhere
descriptionNoWhy this snippet exists — worth writing, since someone will find it later.

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
    • changedInput schema / properties / id / anyOf
      Previous value: -[
      -  {
      -    "type": "integer"
      -  },
      -  {
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "maximum": 9007199254740991,
      +    "minimum": -9007199254740991,
      +    "type": "integer"
      +  },
      +  {
      +    "pattern": "^[a-zA-Z0-9_-]+$",
      +    "type": "string"
      +  }
      +]
  2. First observedv1.0.0

TDQS

A4.4/5.0
Behavior5/5

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

The description adds important behavioral details beyond the annotations: new snippets are always created DISABLED and must be activated in wp-admin after reading the code, and PHP snippets are syntax-checked before saving so parse errors are reported rather than fatalling the site. This is critical safety context not present in the schema or 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?

The description is concise and front-loaded: it states the core value proposition first, then covers the two most important behavioral safety details. No filler or repetition of schema 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?

For a multi-action tool with no output schema, the description thoroughly covers creation behavior and safety. It does not describe list/get/update/delete behavior or return values, but the schema plus the disabled-by-default and syntax-check notes make the tool safely callable for its primary purpose.

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 the parameters are already documented in the schema. The description adds context about creation workflow (disabled by default, syntax-checked) but does not add new per-parameter semantics beyond what the schema already provides.

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 what the tool does: add PHP, CSS, or JavaScript as managed snippets rather than editing theme files. It also names the specific benefit—surviving theme updates and being switchable without touching code—which differentiates it from related theme-file tools.

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?

The description gives clear context for when to use this tool: when you want managed snippets instead of editing theme files, with the advantage of surviving updates. It does not enumerate when not to use it or compare it to plugin creation explicitly, but the primary use case is well specified.

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