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 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.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
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.
kosmo integrations:call servicenow.servicenow_list_incidents '{"query":"example_query","limit":1}' --json 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.
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 - Parameters
- query, limit
kosmo integrations:call servicenow.servicenow_list_incidents '{"query":"example_query","limit":1}' --json 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 - Parameters
- id
kosmo integrations:call servicenow.servicenow_get_incident '{"id":"example_id"}' --json 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 - Parameters
- short_description, description, priority
kosmo integrations:call servicenow.servicenow_create_incident '{"short_description":"example_short_description","description":"example_description","priority":"example_priority"}' --json 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 - Parameters
- id, fields
kosmo integrations:call servicenow.servicenow_update_incident '{"id":"example_id","fields":"example_fields"}' --json 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 - Parameters
- query, limit
kosmo integrations:call servicenow.servicenow_list_tasks '{"query":"example_query","limit":1}' --json 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 - Parameters
- id
kosmo integrations:call servicenow.servicenow_get_task '{"id":"example_id"}' --json 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 - Parameters
- short_description, description, assigned_to, priority
kosmo integrations:call servicenow.servicenow_create_task '{"short_description":"example_short_description","description":"example_description","assigned_to":"example_assigned_to","priority":"example_priority"}' --json 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 - Parameters
- query, limit
kosmo integrations:call servicenow.servicenow_list_users '{"query":"example_query","limit":1}' --json 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 - Parameters
- id
kosmo integrations:call servicenow.servicenow_get_user '{"id":"example_id"}' --json 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 - Parameters
- none
kosmo integrations:call servicenow.servicenow_get_current_user '{}' --json 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
kosmo integrations:schema servicenow.servicenow_list_incidents --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_get_incident --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The sys_id of the incident to retrieve. |
servicenow.servicenow_create_incident 3 parameters
kosmo integrations:schema servicenow.servicenow_create_incident --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_update_incident --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_list_tasks --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_get_task --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The sys_id of the task to retrieve. |
servicenow.servicenow_create_task 4 parameters
kosmo integrations:schema servicenow.servicenow_create_task --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_list_users --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema servicenow.servicenow_get_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The sys_id of the user to retrieve. |
servicenow.servicenow_get_current_user 0 parameters
kosmo integrations:schema servicenow.servicenow_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| 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.