Skip to main content
Glama

hydra_define

Define a reusable GLSL transform for Hydra chains with custom parameters, then use it like a built-in function. Compiles before use to catch GLSL errors.

Instructions

Add a custom transform written in GLSL (Hydra's setFunction), usable in any chain afterwards like a built-in.

type and what the body receives / must return: src _st (vec2 coords) -> vec4 colour coord _st -> vec2 coords color _c0 (vec4 incoming colour) -> vec4 combine _c0, _c1 (two colours) -> vec4 combineCoord _st, _c0 -> vec2 glsl is the function BODY only. inputs are its parameters, in order: [{"name": "amount", "type": "float", "default": 0.5}] (types: float, vec4, sampler2D). For combine types, declare the incoming chain first: {"name": "tex", "type": "vec4"}.

It is compiled inside a throwaway chain before anything goes live, so a GLSL mistake comes back as the compiler's own error. On success it is stored as block fn_<name> at the top of the document (so it is defined again before use when a page reloads) and use shows a call to start from.

Example: hydra_define("stripes", "src", "return vec4(vec3(step(0.5, fract(_st.x * count))), 1.0);", inputs=[{"name": "count", "type": "float", "default": 10}]) then: stripes(20).rotate(0.3).out(o1)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
glslYes
nameYes
takeNo
typeYes
inputsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

The description discloses key behaviors beyond the annotations: it compiles the GLSL in a throwaway chain so errors surface as the compiler's own errors, and on success it stores the function as a block 'fn_<name>' at the top of the document for persistence across reloads. These details are not present in the annotations (which only flag readOnlyHint=false and destructiveHint=false) and are essential for the agent to predict side effects and failure modes.

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 well-structured and front-loaded: it opens with the purpose, then provides a clear list of function types, explains parameter semantics, describes error and storage behavior, and ends with a concrete example. Every sentence contributes useful information, and the formatting with code blocks improves readability. It is appropriately sized for the complexity of the tool.

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 tool with this complexity (GLSL, multiple types, inputs, compilation, persistence), the description is nearly complete. It covers the core semantics, error handling, and storage. The only notable gap is the undocumented 'take' parameter, which could affect usage. An output schema is present, so return values are presumably covered there. Overall, an agent can call this tool correctly with the provided information, but the missing 'take' prevents a perfect score.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It thoroughly explains 'type' with a list of valid values and their behavior, 'glsl' as the body only, and 'inputs' with format and example. However, the 'take' parameter is not mentioned at all, leaving its semantics undocumented. The description adds significant meaning for most parameters but misses one, so it does not fully cover the schema gap.

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 states a specific action: 'Add a custom transform written in GLSL (Hydra's setFunction), usable in any chain afterwards like a built-in.' It clearly identifies the resource (a custom GLSL transform) and distinguishes it from sibling tools that handle other operations. The purpose is unambiguous and specific.

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 provides strong usage context: it explains the available function types (src, coord, color, combine, combineCoord) with their input/output contracts, and includes a complete example. It does not explicitly state when *not* to use it or name alternatives, but the sibling list and the unique nature of defining custom functions make the intended use clear. The example demonstrates exactly how to call it in a chain, which is effective guidance.

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