Skip to main content
Glama

run_script

Execute multi-step Electron automation scripts sequentially with templating, conditional steps, assertions, retries, failure screenshots, and optional Playwright test export.

Instructions

Advanced server-side step runner & workflow engine: executes an array of tool steps sequentially with templating ({{vars.x}}, {{steps[0].result.x}}, {{secret:ELECTRON_MCP_KEY}}; only ELECTRON_MCP_* env vars), conditional branching (if), assertions (expect), automatic retries, diagnostic failure screenshots, and optional export to Playwright test specs.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "script": "<script>"
    },
    "name": "run_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYesArray of steps or path/JSON string to execute
exportAsNoExport the executed steps as executable Playwright test code or JSON recipe
processIdNoTarget process ID. If omitted, uses the single running app.
variablesNoInitial variables map for {{vars.name}} interpolation
exportPathNoOptional file path on disk to save the exported test or JSON recipe
stopOnFirstErrorNoWhether to halt script execution upon first step failure (default: true)
captureFailureArtifactsNoWhether to automatically capture screenshot artifacts and diagnostic logs on step failure (default: true)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.2
    • changedInput schema / properties / script / anyOf
      Previous value: -[
      -  {
      -    "items": {
      -      "additionalProperties": false,
      -      "properties": {
      -        "args": {
      -          "additionalProperties": {},
      -          "description": "Arguments to pass to the tool. Supports {{vars.x}}, {{steps[0].result.x}}, and {{secret:KEY}} templating.",
      -          "type": "object"
      -        },
      -        "assign": {
      -          "description": "Variable name to store this step's output into for subsequent steps",
      -          "type": "string"
      -        },
      -        "delayAfterMs": {
      -          "minimum": 0,
      -          "type": "number"
      -        },
      -        "delayBeforeMs": {
      -          "minimum": 0,
      -          "type": "number"
      -        },
      -        "expect": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "contains": {
      -              "type": "string"
      -            },
      -            "equals": {
      -              "additionalProperties": false,
      -              "properties": {
      -                "path": {
      -                  "type": "string"
      -                },
      -                "value": {}
      -              },
      -              "required": [
      -                "path"
      -              ],
      -              "type": "object"
      -            },
      -            "js": {
      -              "description": "JavaScript predicate expression evaluated with argument 'result'",
      -              "type": "string"
      -            },
      -            "status": {
      -              "enum": [
      -                "success",
      -                "error"
      -              ],
      -              "type": "string"
      -            }
      -          },
      -          "type": "object"
      -        },
      -        "if": {
      -          "description": "Conditional expression; step is skipped if falsy",
      -          "type": "string"
      -        },
      -        "name": {
      -          "description": "Human readable label for this step",
      -          "type": "string"
      -        },
      -        "onError": {
      -          "description": "Whether to abort or continue script on step failure (default: abort)",
      -          "enum": [
      -            "abort",
      -            "continue"
      -          ],
      -          "type": "string"
      -        },
      -        "retry": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "backoff": {
      -              "exclusiveMinimum": 0,
      -              "type": "number"
      -            },
      -            "delayMs": {
      -              "minimum": 0,
      -              "type": "number"
      -            },
      -            "maxAttempts": {
      -              "exclusiveMinimum": 0,
      -              "maximum": 10,
      -              "type": "integer"
      -            }
      -          },
      -          "required": [
      -            "maxAttempts"
      -          ],
      -          "type": "object"
      -        },
      -        "timeoutMs": {
      -          "exclusiveMinimum": 0,
      -          "type": "number"
      -        },
      -        "tool": {
      -          "description": "MCP tool name to invoke (e.g. 'click_ax', 'type_text', 'assert_ui', 'wait_for')",
      -          "type": "string"
      -        }
      -      },
      -      "required": [
      -        "tool"
      -      ],
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "description": "JSON array of steps or path to a .json script file on disk",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "args": {
      +          "additionalProperties": {},
      +          "description": "Arguments to pass to the tool. Supports {{vars.x}}, {{steps[0].result.x}}, and {{secret:ELECTRON_MCP_KEY}} templating (only ELECTRON_MCP_* environment variables can be read).",
      +          "type": "object"
      +        },
      +        "assign": {
      +          "description": "Variable name to store this step's output into for subsequent steps",
      +          "type": "string"
      +        },
      +        "delayAfterMs": {
      +          "minimum": 0,
      +          "type": "number"
      +        },
      +        "delayBeforeMs": {
      +          "minimum": 0,
      +          "type": "number"
      +        },
      +        "expect": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "contains": {
      +              "type": "string"
      +            },
      +            "equals": {
      +              "additionalProperties": false,
      +              "properties": {
      +                "path": {
      +                  "type": "string"
      +                },
      +                "value": {}
      +              },
      +              "required": [
      +                "path"
      +              ],
      +              "type": "object"
      +            },
      +            "js": {
      +              "description": "JavaScript predicate expression evaluated with argument 'result'",
      +              "type": "string"
      +            },
      +            "status": {
      +              "enum": [
      +                "success",
      +                "error"
      +              ],
      +              "type": "string"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "if": {
      +          "description": "Conditional expression; step is skipped if falsy",
      +          "type": "string"
      +        },
      +        "name": {
      +          "description": "Human readable label for this step",
      +          "type": "string"
      +        },
      +        "onError": {
      +          "description": "Whether to abort or continue script on step failure (default: abort)",
      +          "enum": [
      +            "abort",
      +            "continue"
      +          ],
      +          "type": "string"
      +        },
      +        "retry": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "backoff": {
      +              "exclusiveMinimum": 0,
      +              "type": "number"
      +            },
      +            "delayMs": {
      +              "minimum": 0,
      +              "type": "number"
      +            },
      +            "maxAttempts": {
      +              "exclusiveMinimum": 0,
      +              "maximum": 10,
      +              "type": "integer"
      +            }
      +          },
      +          "required": [
      +            "maxAttempts"
      +          ],
      +          "type": "object"
      +        },
      +        "timeoutMs": {
      +          "exclusiveMinimum": 0,
      +          "type": "number"
      +        },
      +        "tool": {
      +          "description": "MCP tool name to invoke (e.g. 'click_ax', 'type_text', 'assert_ui', 'wait_for')",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "tool"
      +      ],
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "description": "JSON array of steps or path to a .json script file on disk",
      +    "type": "string"
      +  }
      +]
  2. First observedv1.0.0

TDQS

A3.9/5.0
Behavior4/5

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

With only destructiveHint=false supplied, the description carries most of the burden and delivers: automatic retries, diagnostic screenshots on failure, abort-vs-continue error semantics, and the security-relevant constraint that only ELECTRON_MCP_* env vars are readable via {{secret:...}}. It does not describe the result envelope that {{steps[0].result.x}} resolves against, which is the main open behavior.

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

Conciseness4/5

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

A single front-loaded sentence establishes the tool's identity before a compact feature list, so an agent reading only the first clause still knows what it does. The trailing parenthetical is dense and packs syntax examples into a small space, but nothing is genuinely redundant.

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 complex nested-schema orchestration tool with minimal annotations and no output schema, the description covers the execution model, error handling, and export surface adequately. The notable hole is what a step result looks like, which matters because steps[0].result.* is a documented interpolation path.

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 schema already documents every parameter, including the templating syntax and env-var restriction. The description restates the templating grammar and asserts the Playwright/JSON export capability but adds little parameter-level meaning beyond the structured fields; baseline 3 applies.

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 ('executes an array of tool steps sequentially') and enumerates the defining capabilities: templating, conditional branching, assertions, retries, failure screenshots, and Playwright export. This clearly separates it from atomic siblings such as click, type_text, or assert_ui, which the description also references as invocable step tools.

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

Usage Guidelines3/5

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

The multi-step orchestration use case is strongly implied by 'array of tool steps sequentially' and the retry/branch/assert features, so an agent can infer this is for chained workflows rather than single actions. However, there is no explicit when-to-use or when-not-to-use statement, and no alternative named (e.g., 'use act_and_verify for a single verify step').

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