SDK Quickstart
The NowAIKit SDK is a TypeScript/JavaScript library for programmatic ServiceNow access. Unlike the MCP integration (which loads ~88K tokens of tool schemas for AI conversations), the SDK provides zero token overhead — direct function calls that compile to clean REST requests. Import it, call a method, get results. v2.0.0 adds the A2A client, OAuth PKCE authentication, SSE streaming, schema caching, a Now Assist client, and Fluent types.
| Characteristic | SDK | MCP |
|---|---|---|
| Token overhead | 0 tokens | ~88K tokens (tool schemas) |
| Interface | Direct function calls | AI tool invocation |
| Language | TypeScript / JavaScript | Any MCP-compatible AI client |
| Best for | Automation, CI/CD, backend | Interactive AI conversations |
| Type safety | Full TypeScript types | JSON schema validation |
When to Use SDK vs MCP
Both the SDK and MCP connect to the same ServiceNow APIs with the same 450+ operations. The difference is how you invoke them.
Use the SDK when you need:
- Automation & CI/CD scripts — Deploy changes, run health checks, or sync data as part of a pipeline. No AI layer needed.
- Token-sensitive scenarios — When every token counts (large context windows, cost optimization), the SDK adds zero overhead.
- Backend services — Build microservices, webhooks, or scheduled jobs that interact with ServiceNow programmatically.
- Custom integrations — Connect ServiceNow to other systems (Slack bots, monitoring tools, internal dashboards) with typed function calls.
- Batch processing — Process thousands of records efficiently with direct API calls and built-in retry logic.
Use MCP when you need:
- Interactive AI conversations — Let Claude, GPT, or Gemini query and modify ServiceNow through natural language.
- Natural language queries — "Show me all P1 incidents from last week" translates to the right API call automatically.
- Tool chaining — AI agents that decide which tools to call based on context and chain operations together.
- Ad-hoc exploration — Investigate incidents, explore CMDB relationships, or debug issues conversationally.
Installation
Install the SDK from npm or use bun:
npm install nowaikit-sdk
bun add nowaikit-sdk
The package includes TypeScript declarations out of the box — no separate @types package needed.
{
"dependencies": {
"nowaikit-sdk": "^2.0.0"
}
}
What's New in v2.0.0
SDK v2.0.0 is a major release that adds six new modules alongside the existing CRUD and fluent query capabilities:
| Module | Import | Description |
|---|---|---|
| A2A Client | nowaikit-sdk/a2a | Agent-to-Agent protocol client — discover agents, send tasks, receive streaming results |
| OAuth PKCE | nowaikit-sdk/auth | Browser-safe OAuth 2.0 with PKCE challenge flow, no client secret required |
| SSE Streaming | nowaikit-sdk/stream | Server-Sent Events streaming for real-time responses from long-running operations |
| Schema Cache | nowaikit-sdk/cache | Local caching of ServiceNow table schemas with TTL, reducing redundant metadata calls |
| Now Assist Client | nowaikit-sdk/now-assist | Interact with ServiceNow Now Assist AI features — generate summaries, suggest resolutions |
| Fluent Types | nowaikit-sdk/fluent | Full TypeScript types for Fluent components — NowConfig, FluentComponent, validation helpers |
A2A Client Quick Example
The A2A (Agent-to-Agent) client enables communication between AI agents using the A2A protocol. Discover agents, send tasks, and receive structured results:
import { A2AClient } from 'nowaikit-sdk/a2a';
const a2a = new A2AClient('http://localhost:3000');
const agent = await a2a.discoverAgent();
const result = await a2a.sendTask({
message: {
role: 'user',
parts: [{ type: 'text', text: 'List active incidents' }]
}
});
console.log(result);
Quick Example
Connect to your ServiceNow instance and start making API calls in seconds:
import { NowAIKit } from 'nowaikit-sdk';
const kit = new NowAIKit({
instance: 'your-instance.service-now.com',
auth: { type: 'basic', username: 'admin', password: 'password' }
});
// Query incidents
const incidents = await kit.incident.query({
active: true,
priority: 1,
limit: 10
});
// Create a change request
const change = await kit.change.create({
short_description: 'Deploy v2.1 to production',
type: 'normal',
risk: 'moderate'
});
console.log(`Found ${incidents.length} P1 incidents`);
console.log(`Created change: ${change.number}`);
Every method is fully typed. Your IDE will autocomplete field names, show parameter types, and flag errors at compile time.
Authentication Options
The SDK supports the same three authentication methods as the MCP integration. Choose the one that fits your environment:
Basic Auth
Simplest option for development and internal tools. Pass username and password directly.
const kit = new NowAIKit({
instance: 'your-instance.service-now.com',
auth: {
type: 'basic',
username: process.env.SN_USERNAME,
password: process.env.SN_PASSWORD
}
});
OAuth 2.0
Recommended for production. Uses client credentials flow with automatic token refresh.
const kit = new NowAIKit({
instance: 'your-instance.service-now.com',
auth: {
type: 'oauth',
clientId: process.env.SN_CLIENT_ID,
clientSecret: process.env.SN_CLIENT_SECRET,
username: process.env.SN_USERNAME,
password: process.env.SN_PASSWORD
}
});
SSO / OIDC (Enterprise)
For enterprise environments with SSO or OIDC identity providers. Pass an existing access token.
const kit = new NowAIKit({
instance: 'your-instance.service-now.com',
auth: {
type: 'token',
accessToken: process.env.SN_ACCESS_TOKEN
}
});
See the OAuth Setup Guide for step-by-step instructions on configuring OAuth in ServiceNow.
Multi-Instance
Connect to multiple ServiceNow instances simultaneously. Each instance gets its own authenticated client:
import { NowAIKit } from 'nowaikit-sdk';
// Production instance
const prod = new NowAIKit({
instance: 'prod.service-now.com',
auth: { type: 'oauth', clientId: '...', clientSecret: '...', username: '...', password: '...' }
});
// Development instance
const dev = new NowAIKit({
instance: 'dev.service-now.com',
auth: { type: 'basic', username: 'admin', password: 'admin' }
});
// Compare incident counts across environments
const prodIncidents = await prod.incident.query({ active: true, limit: 0 });
const devIncidents = await dev.incident.query({ active: true, limit: 0 });
console.log(`Prod: ${prodIncidents.length} active incidents`);
console.log(`Dev: ${devIncidents.length} active incidents`);
For advanced multi-instance patterns (failover, load balancing, environment promotion), see the Full Multi-Instance Guide.
Available Modules
The SDK exposes the same 32 module categories as the MCP integration, covering the full breadth of the ServiceNow platform:
| Category | SDK Module | Description |
|---|---|---|
| ITSM | kit.incident | Incident management — create, query, resolve, close |
kit.problem | Problem management — root cause analysis, known errors | |
kit.change | Change management — normal, standard, emergency changes | |
kit.task | Task management — generic tasks across all modules | |
| ITOM & CMDB | kit.cmdb | Configuration items, relationships, health dashboard |
kit.discovery | Discovery schedules, MID servers, scan management | |
kit.event | Event management — active events, alert correlation | |
| HRSD | kit.hr | HR cases, services, profiles, onboarding/offboarding |
| CSM | kit.csm | Customer service cases, accounts, contacts, products |
| SecOps | kit.security | Security incidents, vulnerabilities, threat intelligence |
kit.grc | Governance, risk, compliance — risks, controls, policies | |
| Development | kit.script | Business rules, script includes, client scripts |
kit.uiPolicy | UI policies and UI actions | |
kit.acl | Access control lists — create, query, manage ACLs | |
| Platform | kit.user | User management — create, update, group membership |
kit.group | Group management — create, update, member management | |
kit.catalog | Service catalog — items, categories, ordering | |
kit.knowledge | Knowledge base — articles, publishing, retirement | |
kit.approval | Approval workflows — approve, reject, list pending | |
kit.sla | SLA management — definitions, active SLAs, breaches | |
| Agile | kit.agile | Stories, epics, sprints, scrum tasks |
| Virtual Agent | kit.va | Topics, conversations, categories |
| ITAM | kit.asset | Assets, software licenses, contracts, lifecycle |
| DevOps | kit.devops | Pipelines, deployments, change tracking |
| Flow Designer | kit.flow | Flows, subflows, actions, execution history |
| Reporting | kit.report | Reports, dashboards, performance analytics |
| Notifications | kit.notification | Email notifications, templates, subscriptions |
| Portal | kit.portal | Service portal pages, widgets, themes |
| UI Builder | kit.uib | UI Builder pages, components, data brokers |
| Integration | kit.rest | REST messages, transform maps, import sets |
| Admin | kit.sys | System properties, update sets, scheduled jobs |
| Advanced | kit.fluent | Fluent GlideQuery-style queries, batch requests, script execution |
Next Steps
You are set up and ready to build. Here is where to go from here:
- SDK API Reference — Full documentation of every module, method, parameter, and return type.
- Fluent Query Guide — Advanced GlideQuery-style queries, batch operations, and server-side script execution.
- OAuth Setup Guide — Configure OAuth 2.0 in ServiceNow for production-ready authentication.
- Multi-Instance Guide — Advanced patterns for managing dev, test, and production environments.
- 450+ Tools Reference — Complete reference for every operation available across all 32 modules.
- Full Documentation — Everything else: MCP setup, client configuration, examples, and more.



