Skip to main content
Glama

Manage code snippets

code_snippet

Insert PHP, CSS, or JavaScript as managed snippets that survive theme updates, with syntax checking for PHP and disabled-by-default activation for safe review.

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.
Behavior4/5

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

Annotations are minimal (readOnlyHint false, destructiveHint false), so the description carries the behavioral transparency burden. It adds key behavioral details: snippets are created disabled by default, PHP syntax is checked before save, and disabling can be done without touching code. It does not mention the confirm requirement for delete or side effects of update, but those are covered in the schema. The description discloses the most critical safety behaviors without contradicting 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 two sentences long and front-loads the core purpose and primary use case. It provides essential safety information (disabled by default, syntax check) without redundancy. Every sentence earns its place, and the structure is logical: first the why-to-use, then critical operational details. No fluff or unnecessary detail.

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 tool's complexity (9 parameters, multiple actions), the description covers the key context: why to use it, safety behaviors, and a hint about activation. It does not explicitly mention the confirm parameter for delete or the site_id fallback behavior, but these are fully documented in the schema. The description is complete enough for an agent to understand the tool's primary purpose and key operational constraints, though it could mention the delete confirmation requirement for completeness.

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 schema covers 100% of parameters with descriptions, so the baseline is 3. The description does not add meaning beyond the schema; it mentions that snippets are created disabled and PHP syntax is checked, which relates to behavior rather than parameter semantics. The schema already explains the opening PHP tag omission and location preferences, so the description adds no extra parameter insight. It neither enhances nor degrades the schema's completeness.

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 manages code snippets by adding PHP, CSS, or JavaScript as managed entities instead of editing theme files. It explicitly names the action (Add) and the resource (snippet), and differentiates from the alternative approach of theme file editing. The purpose is unambiguous and the description distinguishes this tool from siblings like write_theme_file.

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 explicitly advises using this tool over editing theme files, citing survival of theme updates and easy disabling. It also gives important usage context: new snippets are created disabled and must be activated in wp-admin, and PHP snippets are syntax-checked before saving. This provides clear when-to-use guidance and safety instructions, leaving no ambiguity about when to prefer this tool.

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