Skip to main content
Glama

execute_php

Destructive

Run arbitrary PHP inside the full WordPress runtime to query data, call plugin APIs, or inspect returned values as a universal fallback.

Instructions

Execute arbitrary PHP in the full WordPress runtime ($wpdb, WP_Query, get_option, WooCommerce, every loaded plugin API). Do NOT include <?php tags. Use return $value; to return data for inspection; echoed output is captured separately. This is the universal fallback for anything the dedicated tools do not cover.

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>"
    },
    "name": "execute_php"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesPHP code to run. No <?php tags. Return a value to inspect it.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.2

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, so the risk profile is flagged; the description adds genuinely new behavioral context — that the code runs against the complete loaded runtime including plugin and WooCommerce APIs, that no <?php tags are accepted, and that return values are captured for inspection while echo output goes elsewhere. It does not disclose execution limits (timeouts, sandboxing, fatal-error behavior) or permission requirements, which would matter a lot for arbitrary code execution.

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?

Three tight sentences with the execution environment front-loaded, the syntax constraint next, and the positioning as fallback last. No filler, and every sentence carries actionable 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 one-parameter tool with no output schema, the description covers environment, input constraint, and return-channel semantics, and the destructive nature is carried by the annotation. What is missing is failure-mode information — what happens on a fatal error, whether there is a timeout, and whether output is truncated — which would matter for an agent composing arbitrary code.

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?

There is a single parameter at 100% schema description coverage, where the schema already says "No <?php tags. Return a value to inspect it." The description largely restates that, adding only the distinction that echoed output is captured separately from returned values. Baseline 3 is appropriate with the schema doing the heavy lifting.

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 ("Execute arbitrary PHP") and pins the execution context ("full WordPress runtime ($wpdb, WP_Query, get_option, WooCommerce, every loaded plugin API)"). The closing line positions it against the dedicated tools as a universal fallback, so an agent can distinguish it from siblings like execute_sql or manage_option without opening a schema.

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?

Explicitly routes usage: this is the fallback for anything the dedicated tools do not cover, which implies preferring those tools when they apply. It also gives the calling convention for retrieving data (return $value vs echoed output captured separately). It stops short of stating when NOT to use it (e.g. a warning to avoid it for simple reads that have a dedicated tool) or any preconditions such as required capabilities.

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