Skip to main content
Glama
sonisoft-cnanda

now-sdk-ext-mcp

Execute Background Script

execute_script

Execute JavaScript on a ServiceNow instance using background scripts with full GlideSystem API access and optional parameter substitution.

Instructions

Execute JavaScript on a ServiceNow instance using Scripts - Background (the /sys.scripts.do endpoint). The script runs server-side with full GlideSystem API access (gs, GlideRecord, GlideAggregate, GlideDateTime, GlideUser, etc.). Use gs.print() or gs.info() to produce output.

SCOPE BEHAVIOR: Scripts execute within the specified application scope. When running in a scoped app (e.g., scope: 'x_myapp_custom'), you can reference that scope's Script Includes and classes directly by name (e.g., MyUtil.doSomething()) without fully-qualifying them. When running in global scope, scoped classes must be fully-qualified (e.g., x_myapp_custom.MyUtil.doSomething()).

IMPORTANT: This executes code directly on the ServiceNow instance. Always review scripts before execution and prefer read-only operations unless modification is explicitly intended.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceNoThe ServiceNow instance auth alias to execute the script on. This is the alias configured via `now-sdk auth --add` (e.g., "myinstance", "prod", "test"). The user will typically refer to this by name when saying things like "on my myinstance instance". If not provided, falls back to the SN_AUTH_ALIAS environment variable.
scriptYesThe JavaScript code to execute on the ServiceNow instance. Use gs.print() or gs.info() to output results — these are the only ways to capture output from background scripts. The script runs in the server-side Rhino engine with access to all ServiceNow server-side APIs: GlideRecord, GlideAggregate, GlideDateTime, GlideUser, gs.getUser(), gs.now(), GlideSysAttachment, and more. Scripts execute with the permissions of the authenticated user.
scopeNoThe application scope to execute the script in. Accepts either: - A scope name (e.g., "global", "x_myapp_custom", "x_snc_app") — automatically resolved to the corresponding sys_id via the sys_scope table. - A sys_id directly (32-character hex string) if already known. Defaults to "global". Set this to the target app scope when you need to access scoped Script Includes, Business Rules, or other scoped artifacts by their unqualified names.global
paramsNoOptional key-value pairs for parameter substitution in the script. Every occurrence of {paramName} in the script text will be replaced with the corresponding value before execution. Useful for safely injecting dynamic values without string concatenation in the script. Example: { "table": "incident", "field": "priority" } replaces {table} and {field} in the script.
Behavior4/5

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

With no annotations provided, the description carries full burden. It covers server-side execution, full API access, output via gs.print/gs.info, scope behavior, and permission usage. It misses details on error handling, timeouts, or rate limits, but the security warning and scope documentation are strong.

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?

The description is well-structured with headered sections (scope behavior, important notes) and front-loaded with the main purpose. It is appropriately sized, though some sentences could be slightly more concise without losing value.

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 tool's complexity (4 parameters, no output schema), the description is fairly complete. It explains all parameters, scope behavior, and security considerations. Missing output format documentation is acceptable since output is determined by the script itself.

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%, but the description adds meaningful context beyond the schema: instance alias fallback, scope resolution logic, and parameter substitution pattern. This enhances understanding beyond the schema's short descriptions.

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 clearly states 'Execute JavaScript on a ServiceNow instance using Scripts - Background', specifying the exact endpoint and access to GlideSystem APIs. It distinguishes from sibling tools like execute_flow or execute_action which handle workflows, not arbitrary scripts.

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 on when to use this tool, including prerequisites (instance alias) and a security warning. However, it does not explicitly state when not to use this tool or provide alternatives for other execution needs.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sonisoft-cnanda/now-sdk-ext-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server