Skip to main content
Glama

photoshop_execute_script

Run custom ExtendScript (JSX) code in Photoshop to perform operations no existing tool covers. Returns the script's value as text/JSON.

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. Preconditions: valid ExtendScript; active document if script expects one. Side effects: depends on code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesExtendScript code to execute
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 observedv0.1.0

TDQS

A4.7/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 behavioral disclosure burden. It explains the IIFE wrapper, the need for explicit `return`, the serialization via toSource(), automated parsing on macOS/Windows, the active-document precondition, and that side effects depend on the code. This is substantial and honest transparency for an arbitrary-code 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 organized into short labeled sections: use, do-not-use, returns, important IIFE note, preconditions, and side effects. Every sentence adds necessary operational information with no filler, and the critical return quirk is prominently highlighted.

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 arbitrary-code tool with no output schema and no annotations, the description covers what an agent needs: return format, execution semantics, serialization behavior, preconditions, and safety caveats. Nothing essential for correct invocation is missing.

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 does not add extra meaning for the `code` parameter beyond the schema, though it does describe important execution context such as IIFE and return semantics. The `document_id` parameter is adequately documented in the schema itself.

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 and resource: 'Execute custom ExtendScript (JSX) code inside Photoshop' and frames it as an 'advanced escape hatch'. It clearly differentiates this tool from the many atomic photoshop_* and photoshop_recipe_* siblings.

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?

It explicitly says '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 is direct routing guidance with named alternatives.

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