Skip to main content
Glama

photoshop_execute_script

Run custom ExtendScript (JSX) code inside Photoshop when no built-in tool covers the operation. Returns the script result as text or JSON and supports long-running jobs via a custom timeout.

Instructions

Execute custom ExtendScript (JSX) code inside Photoshop (advanced escape hatch).

Use when: no existing tool covers the operation and you can write safe JSX. Do NOT use when: a recipe or atomic tool exists — prefer photoshop_recipe_* or photoshop_* tools.

Returns: script return value serialized as text/JSON. IMPORTANT: Your code runs inside a wrapping IIFE. Use an explicit return to pass data back — a bare trailing expression returns undefined. Example: return { ok: true }; Objects are serialized with toSource() and parsed automatically on macOS and Windows. Long scripts: pass timeout_ms (up to 600000) so the default 30s budget does not kill the job. Preconditions: valid ExtendScript; active document if script expects one. Side effects: depends on code.

Input Schema

NameRequiredDescriptionDefault
codeYesExtendScript code to execute
timeout_msNoScript timeout in milliseconds (default 30000, max 600000). Override with env PHOTOSHOP_SCRIPT_TIMEOUT. Use for long loops, batch jobs, or large documents.
document_idNoOptional Photoshop document id from photoshop_get_state / photoshop_list_documents. When set, the tool activates that document before running so a UI tab switch cannot retarget the edit.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.2

TDQS

A4.9/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: it explains the IIFE wrapper, the need for explicit return, serialization via toSource() and automatic parsing, timeout behavior with defaults and max, preconditions, and that side effects depend on the code. This far exceeds typical behavioral disclosure for an arbitrary execution tool.

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 organized: purpose first, then usage rules, return behavior, timeout guidance, and preconditions/side effects. Each sentence earns its place, and key warnings are front-loaded.

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

Completeness5/5

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

For a high-complexity escape-hatch tool with no output schema and no annotations, the description covers selection logic, execution semantics, return serialization, timeout mitigation, preconditions, and side-effect variability. An agent has enough context to invoke it correctly and avoid common failure modes.

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 coverage is 100%, so the baseline is met; the description goes beyond by explaining the return-value contract for the code parameter (explicit return required, bare expression returns undefined, toSource serialization) and reinforcing when to pass timeout_ms. This adds meaning that the schema alone does not convey.

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 custom ExtendScript (JSX) code inside Photoshop') and explicitly frames itself as an 'advanced escape hatch,' which differentiates it from the many atomic photoshop_* and recipe tools. The name sibling list makes clear this is the generic fallback, not a single-purpose operation.

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

Usage Guidelines5/5

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

Gives explicit use criteria: 'Use when: no existing tool covers the operation and you can write safe JSX' and 'Do NOT use when: a recipe or atomic tool exists — prefer photoshop_recipe_* or photoshop_* tools.' This directly tells the agent when to select this tool versus any of the many siblings.

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