Skip to main content
Glama

execute_background_script

Destructive

Run server-side JavaScript on the instance and return what it returns. The script runs in the global scope inside a run-once Scheduled Script Execution (ServiceNow has no REST endpoint that runs scripts synchronously), so it executes when…

Instructions

Run server-side JavaScript on the instance and return what it returns. The script runs in the global scope inside a run-once Scheduled Script Execution (ServiceNow has no REST endpoint that runs scripts synchronously), so it executes when the instance scheduler picks the job up, normally within seconds. End the script with return <value>; to get a value back (JSON-serialisable; max ~3.5 KB). [Scripting]

Input Schema

NameRequiredDescriptionDefault
scriptYesJavaScript to execute (max 6000 chars). It is wrapped in a function, so `return` works.
wait_secondsNoHow long to wait for the job to run (0-120, default 30). If the scheduler has not run it by then, script_scheduled is returned with the job.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.15.1
    • removedInput schema / properties / scope
      Removed value: -{
      -  "description": "Application scope (default global)",
      -  "type": "string"
      -}
    • changedInput schema / properties / script / description
      Previous value: -"JavaScript code to execute"New value: +"JavaScript to execute (max 6000 chars). It is wrapped in a function, so `return` works."
    • addedInput schema / properties / wait_seconds
      Added value: +{
      +  "description": "How long to wait for the job to run (0-120, default 30). If the scheduler has not run it by then, script_scheduled is returned with the job.",
      +  "type": "number"
      +}
  2. First observedv1.0.2

TDQS

A4.3/5.0
Behavior5/5

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

The description adds substantial behavioral context beyond annotations: execution occurs through a run-once Scheduled Script Execution job picked up by the scheduler, normally within seconds. It also documents the return mechanism (`return <value>;`), JSON-serialisability, and the ~3.5 KB return limit. These details are important for a destructive/open-world arbitrary-code tool and are consistent with the annotations.

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 front-loaded with the core action, followed by execution mechanics and return-value details. Every sentence carries useful information for selecting and invoking the tool, with no redundant filler.

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 high-complexity arbitrary-code execution tool, the description covers the execution model, asynchronous behavior, return-value mechanism, and size limit. Annotations already carry the destructive/open-world/idempotency profile, and there is no output schema to explain. It could additionally mention privilege context or side-effect scope, but the core information needed to call it correctly is present.

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 100%, so the schema already documents both `script` and `wait_seconds`. The description still adds useful meaning by explaining the `return` convention, JSON-serialisable return values, and the ~3.5 KB return limit. It reinforces the wait behavior by noting that if the scheduler has not run the job by then, a scheduled-job result is returned.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb and resource: "Run server-side JavaScript on the instance and return what it returns." It is clear about the execution model and distinguishes itself from client-side/script-record tools by emphasizing background server-side execution. It does not explicitly name a sibling tool for comparison, so it falls short of a 5.

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 clear context for when this tool is appropriate: arbitrary server-side JavaScript execution via a run-once Scheduled Script Execution job. It also explains the asynchronous scheduling behavior and the lack of a synchronous REST endpoint, which shapes when an agent should choose it. It does not explicitly state when not to use it or name alternatives, so it is not a 5.

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