KosmoKrator

productivity

ServiceNow CLI for AI Agents

Use the ServiceNow CLI from KosmoKrator to call ServiceNow tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

ServiceNow CLI Setup

ServiceNow can be configured headlessly with `kosmokrator integrations:configure servicenow`.

Install, configure, and verify
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure servicenow --set username="$SERVICENOW_USERNAME" --set password="$SERVICENOW_PASSWORD" --set instance="$SERVICENOW_INSTANCE" --enable --read allow --write ask --json
kosmokrator integrations:doctor servicenow --json
kosmokrator integrations:status --json

Credentials

Authentication type: Username and password basic. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.

KeyEnv varTypeRequiredLabel
username SERVICENOW_USERNAME Text string yes Username
password SERVICENOW_PASSWORD Secret secret yes Password
instance SERVICENOW_INSTANCE Text string yes Instance Name

Command Patterns

The generic command is stable across every integration. The provider shortcut is shorter for humans.

Generic CLI call
kosmo integrations:call servicenow.servicenow_list_incidents '{"query":"example_query","limit":1}' --json
Provider shortcut
kosmo integrations:servicenow servicenow_list_incidents '{"query":"example_query","limit":1}' --json

Discovery

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

Discovery commands
kosmo integrations:docs servicenow --json
kosmo integrations:docs servicenow.servicenow_list_incidents --json
kosmo integrations:schema servicenow.servicenow_list_incidents --json
kosmo integrations:search "ServiceNow" --json
kosmo integrations:list --json

Automation Contexts

The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.

CLI Functions

Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.

servicenow.servicenow_list_incidents

List incidents from the ServiceNow incident table. Supports filtering via an encoded query string (sysparm_query) and a configurable result limit.

Read read
Parameters
query, limit
Generic call
kosmo integrations:call servicenow.servicenow_list_incidents '{"query":"example_query","limit":1}' --json
Shortcut
kosmo integrations:servicenow servicenow_list_incidents '{"query":"example_query","limit":1}' --json

servicenow.servicenow_get_incident

Retrieve a single ServiceNow incident by its sys_id. Returns the full incident record.

Read read
Parameters
id
Generic call
kosmo integrations:call servicenow.servicenow_get_incident '{"id":"example_id"}' --json
Shortcut
kosmo integrations:servicenow servicenow_get_incident '{"id":"example_id"}' --json

servicenow.servicenow_create_incident

Create a new ServiceNow incident. Provide a short description, an optional full description, and a priority level.

Write write
Parameters
short_description, description, priority
Generic call
kosmo integrations:call servicenow.servicenow_create_incident '{"short_description":"example_short_description","description":"example_description","priority":"example_priority"}' --json
Shortcut
kosmo integrations:servicenow servicenow_create_incident '{"short_description":"example_short_description","description":"example_description","priority":"example_priority"}' --json

servicenow.servicenow_update_incident

Update an existing ServiceNow incident. Provide the incident sys_id and the fields to update.

Write write
Parameters
id, fields
Generic call
kosmo integrations:call servicenow.servicenow_update_incident '{"id":"example_id","fields":"example_fields"}' --json
Shortcut
kosmo integrations:servicenow servicenow_update_incident '{"id":"example_id","fields":"example_fields"}' --json

servicenow.servicenow_list_tasks

List tasks from the ServiceNow task table. Supports filtering via an encoded query string and a configurable result limit.

Read read
Parameters
query, limit
Generic call
kosmo integrations:call servicenow.servicenow_list_tasks '{"query":"example_query","limit":1}' --json
Shortcut
kosmo integrations:servicenow servicenow_list_tasks '{"query":"example_query","limit":1}' --json

servicenow.servicenow_get_task

Retrieve a single ServiceNow task by its sys_id. Returns the full task record.

Read read
Parameters
id
Generic call
kosmo integrations:call servicenow.servicenow_get_task '{"id":"example_id"}' --json
Shortcut
kosmo integrations:servicenow servicenow_get_task '{"id":"example_id"}' --json

servicenow.servicenow_create_task

Create a new ServiceNow task. Provide a short description and optional additional fields.

Write write
Parameters
short_description, description, assigned_to, priority
Generic call
kosmo integrations:call servicenow.servicenow_create_task '{"short_description":"example_short_description","description":"example_description","assigned_to":"example_assigned_to","priority":"example_priority"}' --json
Shortcut
kosmo integrations:servicenow servicenow_create_task '{"short_description":"example_short_description","description":"example_description","assigned_to":"example_assigned_to","priority":"example_priority"}' --json

servicenow.servicenow_list_users

List users from the ServiceNow sys_user table. Supports filtering via an encoded query string and a configurable result limit.

Read read
Parameters
query, limit
Generic call
kosmo integrations:call servicenow.servicenow_list_users '{"query":"example_query","limit":1}' --json
Shortcut
kosmo integrations:servicenow servicenow_list_users '{"query":"example_query","limit":1}' --json

servicenow.servicenow_get_user

Retrieve a single ServiceNow user by their sys_id. Returns the full user record.

Read read
Parameters
id
Generic call
kosmo integrations:call servicenow.servicenow_get_user '{"id":"example_id"}' --json
Shortcut
kosmo integrations:servicenow servicenow_get_user '{"id":"example_id"}' --json

servicenow.servicenow_get_current_user

Get the profile of the currently authenticated ServiceNow user. Useful for verifying credentials and retrieving the logged-in user's details.

Read read
Parameters
none
Generic call
kosmo integrations:call servicenow.servicenow_get_current_user '{}' --json
Shortcut
kosmo integrations:servicenow servicenow_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

servicenow.servicenow_list_incidents 2 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_list_incidents --json
ParameterTypeRequiredDescription
query string no ServiceNow encoded query string to filter results (e.g. "priority=1^state=2"). See ServiceNow query operators for syntax.
limit integer no Maximum number of incidents to return (default: 20).
servicenow.servicenow_get_incident 1 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_get_incident --json
ParameterTypeRequiredDescription
id string yes The sys_id of the incident to retrieve.
servicenow.servicenow_create_incident 3 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_create_incident --json
ParameterTypeRequiredDescription
short_description string yes A brief summary of the incident.
description string no A detailed description of the incident.
priority string no Priority level: "1" (critical), "2" (high), "3" (moderate), "4" (low), "5" (planning). Defaults to the system default if omitted.
servicenow.servicenow_update_incident 2 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_update_incident --json
ParameterTypeRequiredDescription
id string yes The sys_id of the incident to update.
fields object yes An object of field names and their new values. Common fields: state, priority, short_description, description, work_notes, comments, assigned_to.
servicenow.servicenow_list_tasks 2 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_list_tasks --json
ParameterTypeRequiredDescription
query string no ServiceNow encoded query string to filter results (e.g. "active=true^assigned_to=javascript:gs.getUserID()").
limit integer no Maximum number of tasks to return (default: 20).
servicenow.servicenow_get_task 1 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_get_task --json
ParameterTypeRequiredDescription
id string yes The sys_id of the task to retrieve.
servicenow.servicenow_create_task 4 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_create_task --json
ParameterTypeRequiredDescription
short_description string yes A brief summary of the task.
description string no A detailed description of the task.
assigned_to string no The sys_id of the user to assign the task to.
priority string no Priority level: "1" (critical) through "5" (planning).
servicenow.servicenow_list_users 2 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_list_users --json
ParameterTypeRequiredDescription
query string no ServiceNow encoded query string to filter results (e.g. "active=true^department=IT").
limit integer no Maximum number of users to return (default: 20).
servicenow.servicenow_get_user 1 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_get_user --json
ParameterTypeRequiredDescription
id string yes The sys_id of the user to retrieve.
servicenow.servicenow_get_current_user 0 parameters
Schema command
kosmo integrations:schema servicenow.servicenow_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.