Skip to main content
Glama

Theme Preprocess Function

theme_preprocess_function

Add a Drupal theme preprocess function by providing machine name, hook, and code to prepare variables or alter render arrays before template rendering.

Instructions

Add a preprocess function to theme.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
hookYes
pathNo
machine_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

C2.1/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden: it does not say whether this modifies files on disk, whether the theme must exist first, whether it requires specific permissions, or what side effects 'add' entails. Only the word 'add' hints at a mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, front-loaded sentence with no wasted words, but it is sparse to the point of being under-specified rather than genuinely concise. It lacks any structure for conveying usage or parameter meaning.

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

Completeness1/5

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

For a four-parameter mutation tool with no annotations and 0% schema coverage, the description supplies almost nothing. An output schema exists, so return values need not be detailed, but prerequisites, side effects, and parameter meaning are all missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description mentions none of the four parameters (machine_name, hook, code, path). The agent must guess the meaning and format of every argument, including the required hook and code fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb+resource ('Add a preprocess function to theme'), which is clearer than the bare name. However, it does not distinguish this from siblings like theme_template_override or theme_library_create, nor clarify whether 'add' means writing to a .theme file or registering a hook.

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

Usage Guidelines2/5

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

There is no when-to-use, when-not-to-use, or alternative guidance. The agent gets no signal about how this differs from other theme authoring tools in the sibling list.

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