Skip to main content
Glama

validate_php

Validate PHP code against WordPress coding standards to catch hook misuse, security gaps, deprecated functions, and anti-patterns before deployment in plugins or themes.

Instructions

Validate PHP code against WordPress coding standards and best practices. Checks for: correct hook usage, security issues (nonces, escaping, sanitization), deprecated functions, common anti-patterns, proper function prefixing. Context options: plugin, theme, mu-plugin, functions-php, general.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>",
      "conversationId": "<conversationId>"
    },
    "name": "validate_php"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe PHP code block to validate. Include the full code, not just a snippet.
contextNoThe context in which this PHP code is used. Affects which rules are applied.general
revisionNoRevision number when re-validating. Increment this when submitting updated code.
artifactIdNoIf re-validating a previously validated code block, pass the same artifactId.
conversationIdYesThe conversation ID obtained from learn_wordpress_api.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It does useful work by disclosing the rule categories applied and that context changes which rules run, which implies a non-mutating check. However, it never states that the operation is read-only, what the response looks like (pass/fail vs. per-line violations with severity), or any limits on code size.

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, then a compact bulleted list of checks and context values. The trailing 'Context options' sentence is largely redundant with the schema enum and could be dropped without loss.

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

Completeness3/5

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

Five parameters with a two-step re-validation flow (revision/artifactId) and no output schema — the description should say what a result contains so the agent knows how to act on it. It also omits that conversationId must be obtained from learn_wordpress_api, leaving the sequencing prerequisite to the schema alone.

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 coverage is 100%, so the baseline is 3. The description restates the context values already present in the enum but adds no meaning for revision, artifactId, or the re-validation workflow beyond what the schema already says.

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?

States a specific verb and resource ('Validate PHP code against WordPress coding standards') and enumerates exactly what is checked — hook usage, nonces/escaping/sanitization, deprecated functions, anti-patterns, prefixing. This clearly separates it from validate_block_json and validate_theme_template, which validate different artifact types.

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

Usage Guidelines3/5

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

The list of context options (plugin, theme, mu-plugin, functions-php, general) implicitly tells the agent which situations the tool covers, but there is no explicit when-to-use/when-not guidance and no routing to siblings such as debug_wordpress or scaffold_component. Usage must be inferred.

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