Skip to main content
Glama

Attach a script to a sprite or the stage

add_script

Compile a JSON action list into executable Scratch blocks attached under a chosen hat event (e.g., flag click or key press) for a specified sprite or the Stage.

Instructions

Compiles a JSON action list into real Scratch blocks and attaches it under a hat block. Example: {"target":"Cat","when":"flag","do":[{"say":["Hi!",2]},{"forever":[{"move":4},"bounce_on_edge"]}]}. Call dsl_reference for every available action, expression and hat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doYesOrdered list of actions to run under the hat block
whenNoHat block: "flag" (default), "clicked", "clone", {"key":"space"}, {"broadcast":"go"}, "never"
targetYesSprite name, or "Stage"

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full behavioral burden. It does disclose the compilation behavior and hat attachment, but it does not mention whether an existing script is replaced, whether the target must already exist, or what the tool returns.

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 with a compact, high-value example that demonstrates the DSL shape. It front-loads the main purpose and ends with actionable reference guidance, with no redundant or filler content.

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 moderately complex JSON DSL, the description adequately covers the core invocation with an example and directs the agent to dsl_reference for exhaustive syntax. It does not describe return values or side effects, but the pointer to the reference tool fills the main knowledge gap.

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 description coverage is 100%, so the baseline is 3. The description's example adds a practical illustration of the do array and when field, but it does not provide semantic detail beyond what the schema already documents.

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 verb plus resource: it compiles a JSON action list into Scratch blocks and attaches them under a hat block. This clearly distinguishes add_script from sibling tools like add_sprite or add_costume, and the example concretely illustrates the intended operation.

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 gives useful routing guidance by telling the agent to call dsl_reference for every available action, expression, and hat. It does not explicitly state when not to use add_script or contrast it with clear_scripts, but the core usage context is clear.

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