OnlyFlows ServiceNow MCP Server
Governed ServiceNow MCP: per-profile table and field policy, dry-run batches, activity events.
OnlyFlows ServiceNow MCP scores 70 (Good), licensed MIT and written in TypeScript. It installs as a local process. It declares 26 tools. Filed under Uncategorized. GitHub shows 13 stars. Package registries report about 696 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
70 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: mit.
License, quality and maintenance
Quality: Grade A
90/100 for listing completeness. Lost points: short summary, no docs link.
How quality is graded
Where the 70 comes from
22 + 20 + 4 + 10 + 4 + 10 = 70. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 4 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "onlyflowstech-servicenow-mcp": { "command": "npx", "args": [ "-y", "@onlyflows/servicenow-mcp@2.4.0" ] } }}
Environment variables
This server does not declare environment variables.
Tools26Tool docs quality grade C
All capabilitiessn_aggregatetoolCOUNT, AVG, MIN, MAX, SUM with grouping; see Grouped results
sn_atftoolLegacy test/suite listing and results; execution redirects to snatfrun
sn_atf_authortoolCreate tests/suites, ordered memberships and validated typed steps
sn_atf_readinesstoolCheck plugins, properties, Cloud Runner installation and permissions
sn_atf_resultstoolFetch results, cached history and comparisons
sn_atf_runtoolExecute a suite through Cloud Runner only, with bounded polling
sn_attachtoolList attachments, return downloads as inline base64, and upload inline base64 content; never touches a host filesystem path
sn_batchtoolBulk update/delete using a required structured filter and dry-run safety (raw encoded selectors are prohibited; requires confirm: true to execute; a dry run returns the count, up to 5 sample records the profile may read, and the field names
sn_codesearchtoolSearch business rules, script includes, client scripts, etc., with a snippet around each match (Code search). Part of the default read grant, so a plain read grant on a code table allows it
sn_createtoolCreate a record on any table granted for writes, using only field-policy-approved writable fields, including the journal fields comments and worknotes; incident additionally requires a bounded shortdescription
sn_deletetoolDelete a record on an approved write table (requires confirm: true)
sn_discovertoolDiscover tables, scoped apps, store apps, plugins
About
@onlyflows/servicenow-mcp
A governed ServiceNow MCP server: it lets an AI client read and change records on your instances, within limits you set per connection.
Built by OnlyFlows · Published by @onlyflowstech
Governed and safe for production
The server exposes 26 tools over stdio. Every call runs inside controls that you configure and that no tool of this server can change:
- Per-profile table and field policy. Each profile (a named ServiceNow connection) has its own read and write table allowlists. Access is deny-by-default: a profile with no rules denies every ServiceNow call. Field policy decides which fields can be read or written; sensitive field names are refused.
- Confirmation flag on destructive tools.
sn_deleteandsn_batchchange nothing unless the call carriesconfirm: true. The model sets that flag itself, so it is a guard against accidents, not an approval. A person approves through the client's own tool-approval prompt, and many clients let you "always allow" a tool.sn_createandsn_updatetake no confirm flag; keep write grants narrow. - Safe batching.
sn_batchtakes a structured filter (no raw encoded queries), runs as a dry run by default, caps a run at 10,000 records, and never re-sends a batch. - Activity events. Each completed tool call writes one JSON line to stderr with the tool, profile, instance and outcome, plus hashed owner and client labels. It records no table, record or fields. Delivery is best-effort through stderr, and events are dropped above 256 pending lines. Use ServiceNow's own audit history for record changes.
- Explicit profile on every call. There is no default or "active" instance. Each call names its profile, so nothing reaches an instance the call didn't name. Keep write grants on production profiles narrow.
- Credentials stay out of clients. Secrets are entered at a hidden prompt,
verified against the instance before anything is saved, and stored
encrypted in an owner-only
~/.servicenow-mcpdirectory.
Limits of these controls. They hold against the model's tool calls. A client that gives the model a shell or file access (Claude Code and Codex can) could run
servicenow-mcp-setup grantor read~/.servicenow-mcp/server.env. The encryption key sits in the same owner-only folder as the encrypted profiles, so it protects against other users and stray copies of the files, not against your own account. Run production profiles from a client or account without shell access where you can.
Details: Table access policy, Safety Features and docs/PRODUCTION-SECURITY.md.
Works with
Any MCP client that can launch a stdio server. Setup registers Claude Code
and Codex automatically; Claude Desktop, Cursor, VS Code and
Windsurf are configured with servicenow-mcp-setup client --client <name>
(see Connecting a client). Requires Node.js 20 or newer.
Quick start
- Install:
npm install -g @onlyflows/servicenow-mcp - Set up a connection:
servicenow-mcp-setup. It asks for your instance and credential, checks them against the instance, asks which tables to allow, and registers Claude Code and Codex if their CLIs are installed. The wizard's authentication type defaults to OAuth client credentials, so you can press Enter at that prompt. You need an Application Registry entry on the instance first: see OAuth 2.0. Basic is still offered, marked legacy, because ServiceNow is retiring it for REST calls. - Open your client and ask. There is no server to start; the client
launches
servicenow-mcpitself.
The default read grant in the wizard is just incident, and writes default
to none. Grant more later with servicenow-mcp-setup grant.
Try asking
These work with the default read grant (profile named dev):
- "On dev, list the 10 most recent open P1 incidents."
- "On dev, how many incidents are there, grouped by priority?"
- "On dev, which assignment groups have the most incidents?"
- "On dev, which open incidents have no assignee, oldest first?"
- "On dev, show incident INC0010001 and summarize where it stands."
Your client sends profile: "dev" with each call. Asking about other tables
(for example change_request) is denied until you grant them.
Installation
npm install -g @onlyflows/servicenow-mcp
servicenow-mcp-setup
Run bare on a terminal, servicenow-mcp-setup walks you through the whole
thing in one command: it generates the local auth material, asks for your
instance and credential, verifies that credential against the instance,
asks which tables to grant, writes the profile, and registers any supported
client whose CLI is installed. The credential is entered at a hidden prompt —
never an argument, never shell history — and nothing is written to the profile
until the instance has accepted it, so a typo or a wrong password leaves
nothing behind.
ServiceNow MCP setup
This walks through one ServiceNow connection end to end. Nothing is
written to the profile until your credential is verified against the
instance. Press Ctrl+C at any point to stop; nothing will be saved.
Profile name [dev]: dev
ServiceNow instance (for example dev12345.service-now.com): dev12345.service-now.com
Authentication:
1) oauth (default) - client credentials, recommended
2) apikey - inbound API key
3) basic - legacy, not recommended: ServiceNow is retiring it
Choice [1]: 1
OAuth client credentials need these on the instance:
- an Application Registry entry (System OAuth > Application Registry)
with a client ID and client secret
- the client credentials grant enabled for it
- an OAuth Application User: the integration user this server acts as,
with only the roles it needs, not an administrator
Steps: README, section Authentication > OAuth 2.0.
OAuth grant type:
1) client_credentials (default)
2) password
Choice [1]: 1
How should the credential be stored?:
1) encrypted (default)
2) reference
Choice [1]: 1
OAuth client id (not a secret): <your-client-id>
Enter each secret now. Input is hidden — nothing you type from here
is displayed.
clientSecret:
Verifying against the instance...
ok https://dev12345.service-now.com accepted the credential.
Table access is deny-by-default: a profile with no rules denies every
tool call. Grant the narrowest set that does the job; you can add more
later with servicenow-mcp-setup grant.
Tables to allow for READS:
1) Just incident (default)
2) Common ITSM set (incident,change_request,problem,task,sys_user)
3) All tables (*)
4) Enter a custom list
5) None
Choice [1]: 1
Tables to allow for WRITES:
1) Just incident
2) Common ITSM set (incident,change_request,problem,task,sys_user)
3) All tables (*)
4) Enter a custom list
5) None (default)
Choice [5]: 1
Wrote profile dev.
Register this server with codex and claude-code? [Y/n]: y
ServiceNow MCP doctor
ok node: v22.11.0
ok server command: servicenow-mcp resolves on PATH; clients spawn it over stdio
ok config directory: ~/.servicenow-mcp (0700)
ok profile dev: instance: https://dev12345.service-now.com
ok profile dev: credential: oauth clientSecret resolves from its encrypted source
ok profile dev: table access: 1 read, 1 write, 1 target(s)
All checks passed.
Setup complete.
Profile dev
Reads incident
Writes incident
Transport stdio (each client spawns its own servicenow-mcp)
Clients codex, claude-code
Start codex or claude-code and it will launch the server itself.
There is nothing to keep running between sessions.
There is nothing to start. The server speaks stdio: each registered client
spawns its own copy of servicenow-mcp on demand and talks to it over that
process's stdin and stdout. Setup finishes by running the same checks doctor
runs, so you can re-run them any time:
servicenow-mcp-setup doctor --profile dev
npx @onlyflows/servicenow-mcp@latest setup runs the same wizard without a
global install, and servicenow-mcp setup is an alias for
servicenow-mcp-setup.
If you choose Basic and the instance answers 401, the wizard explains the
Basic Auth restriction and asks what next: retry with the same settings,
switch to oauth (it discards the Basic credential and asks the OAuth
questions, keeping the profile name and instance), or stop. Nothing is
saved until a credential verifies.
Scripted setup
Pass any flag, or run without a terminal, and the wizard steps aside for the
original non-interactive behavior — so CI and provisioning scripts are
unaffected. --non-interactive forces it explicitly. Only the interactive
wizard defaults to OAuth. servicenow-mcp-profile create has no default you
should rely on: pass --auth-type oauth (recommended) or --auth-type basic.
Left out, it still creates a Basic profile, as it always has, so existing
scripts keep working, and it prints a deprecation notice only when standard
error is an interactive terminal, so output a script captures is unchanged. A
future release may require the flag.
servicenow-mcp-setup --non-interactive --clients none --json
servicenow-mcp-profile create --name dev --instance https://yourinstance.service-now.com \
--auth-type oauth --client-id <client-id> --source reference --provider env
servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
The servicenow-mcp-setup commands
| Command | Purpose |
|---|---|
servicenow-mcp-setup | Generate local auth material and register supported clients |
servicenow-mcp-setup client --client <name> | Print copy-pasteable config for a client |
servicenow-mcp-setup grant --profile <name> --read <tables> | Add table access rules to a profile |
servicenow-mcp-setup policy show --profile <name> | Print the profile's effective policy as one table (tables, tools, fields, batch limits); never prints a secret |
servicenow-mcp-setup doctor | Diagnose the install and print remedies |
grant and the wizard print a warning, and still grant, when write access
lands on a privilege-sensitive table: role, group, approval, script,
property, user or authentication tables such as sys_user_has_role,
sysapproval_approver, sys_script or sp_widget, and the MID Server queue
(ecc_queue and its rotation shards), whose records can run commands on MID
Server hosts.
--force regenerates the owner/client identifiers but deliberately preserves
SN_PROFILE_ENCRYPTION_KEY, which decrypts every credential envelope in
config.json. Add --help to any command for its full options.
The server runs as you, and the client list is the boundary. Nothing listens on a port, so nothing off this machine can reach it and no web page can drive it. What that leaves is the registration: every MCP client registered here can spawn the server and use whatever ServiceNow access your profiles grant, as your integration account. Keep the grants narrow, and remove a client you no longer use with
claude mcp remove servicenow-mcporcodex mcp remove servicenow-mcp. No ServiceNow credential is copied into a client's configuration file — the spawned server reads the profile and its encryption key from the owner-only~/.servicenow-mcpdirectory.
Connecting a client
servicenow-mcp-setup registers Codex and Claude Code automatically when their
CLI is on PATH. For everything else:
servicenow-mcp-setup client --client claude-desktop
servicenow-mcp-setup client --client all
Every supported client speaks stdio natively, so each one is configured the same way: a command to spawn.
claude mcp add servicenow-mcp -- servicenow-mcp
codex mcp add servicenow-mcp -- servicenow-mcp
stdio is the default transport for both CLIs, so there is no transport flag to pass. For clients configured by file:
{
"mcpServers": {
"servicenow-mcp": { "command": "servicenow-mcp", "args": [] }
}
}
| Client | Configured by | Config location |
|---|---|---|
| Claude Code | claude mcp add or .mcp.json | project or --scope user |
| Codex | codex mcp add or config.toml | ~/.codex/config.toml |
| Cursor | file | ~/.cursor/mcp.json or .cursor/mcp.json |
| VS Code | file ("type": "stdio") | .vscode/mcp.json or user mcp.json |
| Claude Desktop | file | claude_desktop_config.json |
| Windsurf | file | ~/.codeium/windsurf/mcp_config.json |
No client holds a ServiceNow credential. The spawned server resolves its own
from ~/.servicenow-mcp, which is owner-only.
Full per-client blocks are in V2 service and client setup.
servicenow-mcpmust be on the spawning client'sPATH. A global npm install puts it there. If it is not — a project-local install, or a GUI client with a differentPATH— register the absolute entrypoint instead;servicenow-mcp-setup doctorchecks this and prints the exact command.
Guided profile creation from your client
After the bootstrap, a connected MCP client can walk you through profile creation:
Add a ServiceNow MCP profile for https://yourinstance.service-now.com
The MCP prompt is servicenow-mcp.add-profile. It guides profile naming, auth
mode, and least-privilege default-deny access, and deliberately does not
ask you to paste passwords, API keys, bearer tokens, OAuth client secrets, or
encryption keys into chat.
What gets installed
servicenow-mcp— the MCP server itself, spawned by a client over stdioservicenow-mcp-profile— manages profile credentials out of bandservicenow-mcp-setup— bootstrap, client config, grants, and diagnosis
Manual configuration without the bootstrap
The server keeps configuration explicit. A manual run needs:
- audit identity:
MCP_OWNER_IDandMCP_CLIENT_ID(optional; they label audit records and default tolocal-owner/local-client) - one named ServiceNow profile, either in
~/.servicenow-mcp/config.jsonor throughSN_PROFILE_NAME+SN_INSTANCE+ auth-specificSN_*variables - per-profile table access rules; unconfigured access denies everything
The SN_* environment path builds a profile only when
~/.servicenow-mcp/config.json does not exist. Once you create a profile
file, SN_ALLOWED_READ_TABLES, SN_ALLOWED_WRITE_TABLES, and
SN_TABLE_ACCESS_TARGETS stop applying and the rules must live on the profile
(servicenow-mcp-setup grant). This is the most common cause of a server that
denies every call; servicenow-mcp-setup doctor detects it.
The server reads ~/.servicenow-mcp/server.env itself at startup, because the
client that spawns it supplies its own environment and will not have sourced
anything. A value already present in the environment always wins over that
file, so container and CI configuration is unaffected.
For a quick environment-only run with no profile file — driving the server by hand over a pipe, or from a client that passes environment variables — inject protected values from your keychain or secret manager and pass only non-secret values on the command line:
MCP_OWNER_ID=local-owner \
MCP_CLIENT_ID=local-client \
SN_PROFILE_NAME=dev \
SN_INSTANCE=https://yourinstance.service-now.com \
SN_AUTH_TYPE=oauth \
SN_CLIENT_ID=your-non-secret-client-id \
SN_ALLOWED_READ_TABLES=incident,problem,change_request \
SN_ALLOWED_WRITE_TABLES=incident,change_request \
SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]' \
servicenow-mcp
Do not put SN_PASSWORD, OAuth client secrets, or API keys in command history.
Inject them into the server's environment from your approved secret mechanism,
or leave them in the owner-only profile file where the server can resolve them
without any client seeing them.
Source install for development
Use source install only for development or unreleased changes:
git clone https://github.com/onlyflowstech/servicenow-mcp.git
cd servicenow-mcp
npm install
npm run build
npm start
For local development with a rebuild and source maps:
npm run dev
Container deployment applies to the dormant HTTP transport rather than a 2.0 stdio install; see Production container deployment and the enterprise boundary.
Multi-Instance Profiles
Manage multiple ServiceNow instances (dev, test, prod, PDI) with named profiles. Every tool call must select one configured profile explicitly; V2 has no active-profile or default-profile fallback.
Setup
Create profiles with the CLI rather than by hand — it captures credentials without putting them in argv, and it writes the file with the right ownership and mode:
servicenow-mcp-profile create --name dev --instance https://mydev.service-now.com --auth-type oauth --client-id <dev-client-id> --source reference --provider env
servicenow-mcp-profile create --name prod --instance https://myprod.service-now.com --auth-type oauth --client-id <prod-client-id> --source reference --provider env
servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
servicenow-mcp-setup grant --profile prod --read incident
The resulting ~/.servicenow-mcp/config.json looks like this. Note
tableAccess: a profile without it denies every tool call.
{
"version": 2,
"profiles": {
"dev": {
"instance": "https://mydev.service-now.com",
"authType": "oauth",
"clientId": "your-dev-client-id",
"clientSecret": { "type": "secret_ref", "provider": "env", "reference": "SN_CLIENT_SECRET_DEV" },
"description": "Development instance",
"tableAccess": {
"readTables": ["incident", "problem"],
"writeTables": ["incident"],
"targets": [
{
"table": "incident",
"kind": "canonical",
"tools": [
"sn_query", "sn_get", "sn_aggregate", "sn_schema", "sn_codesearch",
"sn_create", "sn_update",
"sn_incident_add_comment", "sn_incident_add_work_note"
],
"closureComplete": true,
"relatedTables": ["incident"]
},
{
"table": "problem",
"kind": "canonical",
"tools": ["sn_query", "sn_get", "sn_aggregate", "sn_schema", "sn_codesearch"],
"closureComplete": true,
"relatedTables": ["problem"]
}
]
}
}
}
}
Have the approved supervisor, orchestrator, keychain, or secret manager provide
the values referenced by SN_CLIENT_SECRET_DEV and SN_CLIENT_SECRET_PROD in the
environment the server is spawned with, or in ~/.servicenow-mcp/server.env,
which the server falls back to. Do not type either value into a shell command,
command argument, dotenv file, or command history.
Each targets entry must set the literal closureComplete: true, and its
relatedTables must include the target table itself. relatedTables is a
declaration that the loader checks for consistency: every related table must
be in the allowlist of each operation the target is in, or the profile is
rejected. The loader does not derive it from the instance. ServiceNow returns
inherited fields through the child table's own endpoint, so a self-only list
such as ["incident"] is enough to read them. Declaring the immediate parent,
as servicenow-mcp-setup offers, is optional:
servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task.
That adds task to the read allowlist, because the loader requires it, and a
later grant that gives change_request another operation adds task to that
operation's allowlist too. On its own this makes task addressable by no tool,
because it has no target of its own, unless such an allowlist is *. If
task has, or later gets, a target of its own, that target's tools can then
use those operations on it, so declare a table only where every tool on its
own target may use every operation the declaring target has or will have.
A grant on a base table such as task reaches the records of the tables that
extend it, such as incident, whatever relatedTables lists, so grant a base
table only when those records should be reachable through it. Likewise, a
view or alias returns data from every table it reads, whatever
relatedTables lists: declare each of those tables, so the loader requires
each to carry the same permission, and grant the view only when all of that
data should be reachable.
Credential Options
| Format | Example | Description |
|---|---|---|
| Legacy environment reference | "env:SN_PASSWORD_DEV" | Read-compatible V1 form; migrated to a structured reference on the next write |
| Secret reference | {"type":"secret_ref","provider":"env","reference":"SN_PASSWORD_DEV"} | Provider-neutral reference resolved only for the selected request |
| Encrypted envelope | {"type":"encrypted","version":1,...} | AES-256-GCM value created by the protected administration CLI |
Plaintext profile secrets are rejected. Use the installed servicenow-mcp-profile
operator command to create, inspect, rotate, or remove profiles; it reads secrets
through a protected prompt or bounded standard input and rejects credential-bearing
command-line arguments. Encrypted sources require exactly 32 random bytes encoded
as base64 or base64url in SN_PROFILE_ENCRYPTION_KEY, supplied separately by the
deployment secret mechanism and never stored in the profile file. See the
profile credential and administration guide.
The legacy env:VAR_NAME indirection remains readable for every secret field:
credential, clientSecret, and apiKey.
Using Profiles
Pass the profile parameter on every tool call:
- "query incidents on prod" — calls
sn_querywithprofile: "prod" - "get incident INC0010001 on dev" — calls
sn_getwithprofile: "dev" - "show me the dev profile endpoint" — calls the read-only
sn_profilediagnostic withprofile: "dev"
Profiles are created and changed out of band by the service operator. Legacy
default_profile metadata is ignored and is not persisted on the next
administrative write; the MCP boundary never consults it.
SN_* configuration compatibility
If no config file exists, canonical SN_* connection values are exposed only
through an explicit SN_PROFILE_NAME mapping. For example, set
SN_PROFILE_NAME=dev with SN_INSTANCE, SN_AUTH_TYPE=oauth, SN_CLIENT_ID
and SN_CLIENT_SECRET, then call tools with profile: "dev". Without
SN_AUTH_TYPE the environment profile is Basic (SN_USER and SN_PASSWORD),
as it has always been; set SN_AUTH_TYPE explicitly. Without SN_PROFILE_NAME, bare connection
variables create no profile and cannot route a request. Secret values remain
runtime-only environment references and are never persisted as plaintext.
Authentication
Three ServiceNow auth types are available per profile, selected with authType. The setup wizard and every example here use OAuth client credentials. A saved profile that has no authType is read as Basic, because that is what such a profile has always meant; saved profiles are never rewritten. Profile configuration is managed out of band by the service operator. This is the only authentication involved: the transport is stdio, so there is no endpoint in front of the server to protect.
Heads up: ServiceNow's inbound Basic Auth restriction program is phasing out basic auth for API requests — instances can start hard-rejecting it at any time (exemptions: Web-Service-Access-Only accounts or the
snc_basic_auth_api_accessrole). OAuth is the recommended auth type. The server prints a startup warning for basic-auth profiles.
OAuth 2.0 (recommended)
client_credentials grant (default). On the instance you need three things:
- An Application Registry entry, an OAuth API endpoint for external clients (System OAuth → Application Registry), which gives you a client ID and a client secret.
- The client credentials grant enabled for it: on current releases the system property
glide.oauth.inbound.client.credential.grant_type.enabledmust betrue. - An OAuth Application User set on that entry: the integration user the server acts as. Give it the least roles that do the job, not an administrator.
Then create the profile with the wizard (servicenow-mcp-setup, press Enter at the authentication prompt) or servicenow-mcp-profile create --auth-type oauth --client-id <client-id>, or reference the secret via env: indirection:
{
"version": 2,
"profiles": {
"dev": {
"instance": "https://mydev.service-now.com",
"authType": "oauth",
"clientId": "your-oauth-client-id",
"clientSecret": "env:SN_CLIENT_SECRET",
"description": "OAuth client_credentials"
}
}
}
password grant — set grantType and provide the user credentials as well:
{
"instance": "https://mydev.service-now.com",
"authType": "oauth",
"grantType": "password",
"clientId": "your-oauth-client-id",
"clientSecret": "env:SN_CLIENT_SECRET",
"username": "integration.user",
"credential": "env:SN_PASSWORD_DEV"
}
Tokens are cached until shortly before their expires_in expiry and refreshed automatically (including a single refresh + retry on 401). Token responses are never logged.
API key
For instances using Inbound Authentication Profiles with API keys. The header name is configurable (default x-sn-apikey):
{
"instance": "https://mydev.service-now.com",
"authType": "apikey",
"apiKey": "env:SN_API_KEY",
"apiKeyHeader": "x-sn-apikey"
}
Basic (legacy, deprecated by ServiceNow)
Basic is no longer the wizard's default. Use it only for an instance that still accepts it.
{
"instance": "https://mydev.service-now.com",
"username": "admin",
"credential": "env:SN_PASSWORD_DEV"
}
On a 401 for a basic-auth profile, the error explains the Basic Auth restriction program (KB3096078): the role snc_basic_auth_api_access or a Web-Service-Access-Only account is needed, and OAuth is the recommended way to move off Basic Auth. The setup wizard gives the same explanation when it verifies the credential.
Timeouts & retries
Every request is bounded by a timeout (default 30s; per-profile timeoutMs or env SN_TIMEOUT_MS) and retried up to twice with exponential backoff on 429/502/503/504, honoring Retry-After. POST requests are only retried on 429 — never after a 5xx that may have executed side effects.
ServiceNow upstream can return HTTP 429 with an empty body, while this server's own HTTP rate-limit rejections return a short JSON body plus Retry-After. Treat the status and Retry-After header as authoritative; do not benchmark or validate tool success from response latency or body shape alone. In normal ServiceNow instances, plan around the Background throttling default of roughly 120 requests per 60 seconds per identity unless the instance limit is explicitly raised.
What the tools cover
The registered catalog has 26 tools (see Tools Reference):
| Area | Tools |
|---|---|
| Records | sn_query, sn_get, sn_create, sn_update, sn_delete, sn_batch |
| Incident journals (append-only) | sn_incident_add_comment, sn_incident_add_work_note |
| Analytics and schema | sn_aggregate, sn_schema, sn_health |
| CMDB and operations | sn_relationships, sn_attach, sn_syslog, sn_codesearch, sn_discover |
| ATF | sn_atf_author, sn_atf_run, sn_atf_results, sn_atf_readiness, sn_atf |
| Flow Designer (read-only) | sn_flow_view |
| Record history and platform views (read-only) | sn_history, sn_platform_view |
| Profiles | sn_profile |
| Natural language | sn_nl (currently policy-denied pending a typed access plan) |
Every tool requires a profile, and every tool is subject to the profile's
table and field policy. sn_script (background scripts) is not registered; see
the Roadmap.
Manual environment setup
The server speaks stdio and requires Node.js 20 or newer. The shortest path is the bootstrap described under Installation:
servicenow-mcp-setup
That registers your clients; each one spawns the server when it needs it.
The rest of this section is the manual environment path, for a deployment that injects everything from a supervisor or secret manager, or for driving the server by hand over a pipe.
Use .env.example only as a non-secret configuration
inventory. Its protected-value assignments are intentionally empty; inject
ServiceNow secrets through a supervisor, orchestrator, keychain, or secret
manager rather than filling a repository dotenv file.
The
SN_ALLOWED_*andSN_PROFILE_NAMEvariables below build a profile only when~/.servicenow-mcp/config.jsondoes not exist. With a profile file present, put the rules on the profile withservicenow-mcp-setup grant.
export MCP_OWNER_ID="your-owner-id"
export MCP_CLIENT_ID="your-client-id"
export SN_ALLOWED_READ_TABLES="incident,problem,change_request"
export SN_ALLOWED_WRITE_TABLES="incident,change_request"
export SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]'
export SN_PROFILE_NAME="dev"
export SN_INSTANCE="https://yourinstance.service-now.com"
export SN_AUTH_TYPE="oauth"
export SN_CLIENT_ID="your-non-secret-oauth-client-id"
npm run build
npm start
Before running those non-secret commands, the approved runtime secret mechanism must already have injected the authentication-specific ServiceNow secret into the process. Do not enter it in this shell block.
A client connects by spawning the command; there is no URL and no header:
{
"mcpServers": {
"servicenow-mcp": { "command": "servicenow-mcp", "args": [] }
}
}
JSON-RPC messages travel on the child's stdin and stdout, one newline-delimited message per frame. Everything else the server reports — startup warnings, and one structured JSON-line event per completed tool call — goes to stderr, which your client captures as its server log. There is no per-message size limit imposed by the transport.
For complete official SDK and independent client examples, safe two-profile setup, and crossed profile/result/audit checks, see V2 service and client setup.
Breaking changes in 2.0
Every tool call must name a profile, and table access is deny-by-default.
Those two require action on every install. The transport is stdio, as it was in
1.0.0, so a client configured with a command entry keeps working.
The breaking changes from 1.0.0, each with a before/after example, are in
Migrating to 2.0.
Already on 2.x? 2.2.0 changes field-policy loading and journal writes, and can refuse to start on a configuration that loads today. Read Upgrading to 2.2.0 first.
Deployment guides for the dormant HTTP transport
2.0 ships stdio only. The container image, the health and shutdown contract, the operations runbook, and the Secure MCP Tunnel adapter all describe the dormant HTTP transport, which no CLI path reaches. They are kept because that transport is a planned enterprise deployment shape, not because they apply to a 2.0 install — nothing in this section is needed to use this server.
- Production container deployment — OCI artifact, non-root runtime, provenance and scanning
- Remote operations runbook — health interpretation, telemetry, alerts, rotation, incident response
- Private ChatGPT connectivity — outbound-only Secure MCP Tunnel adapter
Tools Reference
Core CRUD
| Tool | Description |
|---|---|
sn_query | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule. Paging runs on has_more and next_offset, which can end early if ServiceNow ACLs strip rows from a page; cross-check with sn_aggregate COUNT. A page cut to fit max_response_bytes keeps the same contract: see Paging when a response is cut to size |
sn_get | Get a single record by sys_id from an approved table |
sn_create | Create a record on any table granted for writes, using only field-policy-approved writable fields, including the journal fields comments and work_notes; incident additionally requires a bounded short_description |
sn_update | Update one record selected by exact sys_id on any table granted for writes, using only field-policy-approved writable fields; comments and work_notes append a journal entry |
sn_incident_add_comment | Append one bounded customer-visible comment to an incident; repeated calls append again |
sn_incident_add_work_note | Append one bounded internal work note to an incident; repeated calls append again |
sn_delete | Delete a record on an approved write table (requires confirm: true) |
sn_batch | Bulk update/delete using a required structured filter and dry-run safety (raw encoded selectors are prohibited; requires confirm: true to execute; a dry run returns the count, up to 5 sample records the profile may read, and the field names it would write). Values get the same policy as sn_update; execution uses the ServiceNow REST Batch API and never re-sends a batch |
Analytics & Schema
| Tool | Description |
|---|---|
sn_aggregate | COUNT, AVG, MIN, MAX, SUM with grouping; see Grouped results |
sn_schema | Table field definitions, types, references |
sn_health | Instance version, cluster nodes, stuck jobs, key stats |
sn_aggregate grouped results
ServiceNow's Stats API does not page grouped results: it ignores
sysparm_limit and sysparm_offset and returns every group. With
group_by, sn_aggregate therefore makes one request, orders the groups
itself and pages them with offset and limit, so offset is a true group
offset and every page differs. The order is the tool's own: the groups'
values in code-unit order (the display value first with display_value: "all"),
the same on every call.
- Paging.
metadata.pagination(andhas_moreandnext_offsetin the data) say whether another page exists and where it starts; a page cut to fit the response size continues at the first group not returned. Withoutgroup_bythe result is one row and is not paged. - Total.
total_groupsis the number of groups when every group was read and kept. A list with groups missing (cut at the cap, or left out by response limits or field policy) has no total. - Cap. One call reads at most 5,000 groups (a group is about 100 to 150
bytes, so that fits the 1 MiB upstream response limit). When more exist,
only the first 5,000 in the instance's order by the group field can be paged
(the same 5,000 whether or not the instance honours
sysparm_limit):total_groupsis left out,truncatedis true,metadata.truncationsaysrecord_limit, andwarningssays to group by a field with fewer distinct values. If the group list is too large to read in one response at all, the call fails with the usual too-large error (loweringlimitdoes not help, since the whole list is read): group by a field with fewer distinct values, or usedisplay_value: "false", which makes each group smaller. The request always asks for up to 5,001 groups, even for a smalllimit: an instance that does honoursysparm_limitthen sends more groups than a small page needs, a deliberate trade for one request and a stable order. The text of a result gives the group total, or the cap warning, after the paging line.
CMDB & Operations
| Tool | Description |
|---|---|
sn_relationships | CMDB CI graph traversal, breadth first — upstream/downstream/both, configurable depth, optional map with a Mermaid diagram (CMDB relationship traversal) |
sn_attach | List attachments, return downloads as inline base64, and upload inline base64 content; never touches a host filesystem path |
sn_syslog | Query system logs with severity/source/time filters, newest first. tail: true starts a tail (the newest entries, oldest first, plus a cursor); each later call with after_cursor returns only the entries after it, oldest first, plus a new cursor (Tailing the system log) |
sn_codesearch | Search business rules, script includes, client scripts, etc., with a snippet around each match (Code search). Part of the default read grant, so a plain read grant on a code table allows it |
sn_discover | Discover tables, scoped apps, store apps, plugins |
CMDB relationship traversal
sn_relationships walks cmdb_rel_ci outward from one CI, level by level,
to depth (1 to 5, default SN_REL_DEPTH or 3).
- Start. Pass
sys_id, orci_name. A name that matches more than one CI is refused with the matches (name, class,sys_id; up to 5, and a note when there are more), so the retry names the one you mean. A unique name works. - Shortest depth, each CI once. Every CI appears once, at its shortest
distance from the start, with the
typeanddirectionof the relationship that first reached it andvia, the sys_id of the CI it was reached from. The start CI is never listed. Rows come nearest first; within a depth, in the order of the frontier's chunks of 50 CIs, then of the relationship rows (bysys_id), so a longer call lists the same CIs first. - Direction is in the query.
downstreamreads relationships where the CI is the parent,upstreamwhere it is the child,botheither.impact: trueisupstreamonly. - Filters.
typeis a substring of the relationship type; relationships of other types are skipped, so nothing is walked through them; the filter is also sent in the query (type.nameLIKE) and checked on the rows.classlimits which CIs are listed, not which are walked through. - Paging.
limitandoffsetpage the list. The walk reads only as much as the page needs: it stops once the page and one more CI are known, which is what makeshas_moretrue, and it asks for no more relationship rows and CIs than that takes.meta.totalis the number of CIs found, so a lower bound whilehas_moreis true.traversal_truncatedis set only when a limit stopped the walk before the page was full or the depth was reached. - Relationship types. Each relationship row is read with its ends as bare
sys_ids and its type's name (a dot-walk of
type); no display value of a CI is requested fromcmdb_rel_ci. - Requests. Each level reads its CIs in batches (50 CIs per
cmdb_rel_ciquery, 100 percmdb_ciread), paging through a CI with more relationships than a page holds.meta.traversal_requestscounts every upstream request the call made: the start lookup, relationship pages and CI reads.
Limits on one call. A limit that stops a walk sets meta.traversal_truncated,
names the limit in meta.truncated_by (cap, its max, the depth, and
unread_cis), and adds a warning that names the CIs whose relationships were
not fully read.
| Limit | Value |
|---|---|
| Upstream requests (start lookup, relationship pages and CI reads together) | 50, of which 15 are kept for reading CIs |
| CIs read (the start CI aside) | 1,000 |
| Relationship rows read (a row read from each end counts twice) | 2,000, in pages of 500 |
| Upstream response bytes | The client allows 1 MiB of JSON per call. The walk keeps its own estimate and stops short of it (640 KiB for relationship rows, 180 KiB for CI reads). |
| Output | limit up to 1,000 CIs; max_response_bytes (default 100,000, 1,000 to 1,000,000, as for sn_query) bounds the whole response. Rows that do not fit are dropped from the end, with next_offset to continue; a budget too small for any result is refused, saying to raise it |
Relationships between two CIs that are both at the depth limit are not read.
CIs the profile cannot read. Relationship rows are not domain separated,
and the display values of their parent and child are not filtered by the
CI's own access rules, so nothing shown about a CI comes from them. The tool
reads each level's new CIs from cmdb_ci, where the instance applies the
profile user's ACLs and domain visibility, and the profile's field policy for
cmdb_ci decides which fields are shown: a name or sys_class_name the
profile cannot read is left out. A CI that read does not return is not shown
and is not walked through; meta.unreadable_relationships and a warning give
only a count. If parent, child or type of cmdb_rel_ci, or sys_id of
cmdb_ci, is not readable under field policy, the call is refused. ci_name
and type may be up to 255 characters and class up to 80. See
Production security.
Map. map: true adds nodes (the start CI and the CIs listed), edges
(each relationship once, by its row's sys_id, with parent, child and
type) and diagram, a Mermaid flowchart TD with arrows from parent to
child. The map covers the page of CIs the call lists (nothing more is read for it), so limit and offset
page it, and the same field policy applies to every CI attribute in it. The
diagram draws the nearest 149 CIs at most (150 nodes, 300 edges, 20,000
characters) and collapses the rest into one node, saying how many in
diagram.omitted_nodes; the map takes at most 48% of max_response_bytes (about 48,000 bytes by
default), and meta.map_omitted_cis says how many listed CIs it had to leave
out. The shared sn_flow_view diagram grammar has no edge labels, so diagram
edges carry no relationship types; they are in edges.
Tailing the system log
sn_syslog can follow the log without re-reading it. The first call sends
tail: true and gets the newest limit entries (inside the since window),
oldest first, and a cursor. Each later call sends that cursor as
after_cursor and gets only the entries created after it, oldest first, and a
new cursor; poll no faster than every few seconds.
- No skips, no repeats. Many log rows share one
sys_created_onsecond, so the cursor holds the second and the row'ssys_id, and a call returns the rows after that pair. It is an opaque token: pass it back as given. has_more. If more thanlimitentries are waiting, the call returnslimitof them withhas_more: trueand a cursor at the last one; call again with it. A response cut to fit the byte budget does the same, and the cursor always names the last entry actually returned. Tail pages carry nototaland nonext_offset, andoffsetcannot be combined with a tail.- Same filters on every call. The cursor is bound to the
level,sourceandmessageit was issued for. A call that changes them is refused (so is a malformed, oversized or altered cursor) with a fixed message that does not repeat the cursor.sinceapplies to the first call only, but a cursor older than the longestsince(525,600 minutes, one year) is refused with a fixed message: start a new tail. With nothing to return, the call gives the same position back, so keep polling with it. If the first call finds no entries in its window it returns no cursor; call it again. - Reads go straight to the instance, never through the metadata cache, and
use the same table and field policy as an ordinary
sn_syslogread. A tail also readssys_idandsys_created_onto place the cursor, so a field policy that withholds either refuses it. - Limits. Order is by creation second, then
sys_id. A row the instance stores late with a creation time at or before the cursor's second is not seen by a tail that has already moved past it.
Testing & Automation
| Tool | Description |
|---|---|
sn_atf_author | Create tests/suites, ordered memberships and validated typed steps |
sn_atf | Legacy test/suite listing and results; execution redirects to sn_atf_run |
sn_atf_readiness | Check plugins, properties, Cloud Runner installation and permissions |
sn_atf_run | Execute a suite through Cloud Runner only, with bounded polling |
sn_atf_results | Fetch results, cached history and comparisons |
sn_nl | Currently fails closed until natural-language composition emits a complete typed access plan |
sn_script (background script execution) shipped in 1.0.0 as an unimplemented
stub and is not published in 2.0 — it does not appear in tools/list. Use
sn_query and sn_batch instead. See Roadmap.
Flow Designer
| Tool | Description |
|---|---|
sn_flow_view | Show a flow or subflow as a Mermaid diagram, an outline and a structured graph: trigger, steps, branches, loops, error handling, input values under field policy, and called subflows to depth 3. Read-only through the Table API; never calls Flow Designer's internal API. See docs/FLOW-VIEW.md |
Record history and platform views
| Tool | Description |
|---|---|
sn_history | One record's history, newest first: audited field changes with old and new values, comments and work notes, and the flows that ran on it. Pages by a cursor per source. Values follow field policy and the field's dictionary type. sys_audit and sys_journal_field must be granted by name; see docs/HISTORY.md |
sn_platform_view | Read-only platform views chosen by view: update_sets, update_set, changes (with one change's XML, masked, when the profile names payload), batch, remote_update_sets (with preview problems), upgrade_skipped, scan_findings and evaluate (heuristic rules over an update set's changes). See docs/PLATFORM-VIEW.md |
Profile Management
| Tool | Description |
|---|---|
sn_profile | Inspect non-secret metadata and the effective policy card for one explicitly named profile; profile configuration is operator-managed out of band |
Environment Variables
MCP runtime
| Variable | Required | Default | Description |
|---|---|---|---|
MCP_OWNER_ID | ❌ | local-owner | Stable non-secret owner identifier recorded in request/tool context and every audit record. A label, not a credential; it is never checked. |
MCP_CLIENT_ID | ❌ | local-client | Stable non-secret client identifier recorded in request/tool context and every audit record. A label, not a credential; it is never checked. |
That is the whole list. There is no bind address, port, Host/Origin
allowlist, concurrency cap, connection cap, shutdown grace period, bearer
token, or rate limit, because there is no listener: a client spawns the server
and owns its lifetime.
The server reads these from its environment and falls back to
~/.servicenow-mcp/server.env for any it does not find there. That file is
owner-only (mode 0600) and is where servicenow-mcp-setup writes the
generated identifiers and SN_PROFILE_ENCRYPTION_KEY. It exists because the
client that spawns the server supplies its own environment and will not have
sourced anything. A value already present in the environment always wins, so a
container or CI runner that passes configuration directly is unaffected.
servicenow-mcp-setup doctor reports that file's mode and contents.
Observability
Each completed tool call emits one JSON-line event to stderr, which the spawning client captures as its server log:
{"schemaVersion":1,"type":"mcp_tool","observedAtMs":1737000000000,"latencyMs":42,
"correlationId":"stdio-<session>-<invocation>","ownerIdHash":"sha256:...",
"clientIdHash":"sha256:...","tool":"sn_query","profile":"dev",
"instance":"https://dev00001.service-now.com","outcome":"success","reason":null,
"errorCategory":null,"retry":null,"retryAfterSeconds":null}
Tool audits classify request cancellation and request-deadline expiration
separately from handler failures. Configured owner/client identifiers are
represented only by SHA-256 pseudonyms; headers, URLs/query strings, bodies,
credentials, tokens, config objects, and exception text are not event fields.
Telemetry never blocks a tool result: stderr backpressure retains at most 256
pending lines, drops excess events, and emits a
{"type":"telemetry_dropped","count":N} summary after the stream drains.
A correlation ID is stdio-<session>-<invocation>. The session half is fixed
for the life of one spawned server, so every record from one client session
groups together; the invocation half is fresh per call. Neither half is derived
from anything the caller sent.
stdout carries the protocol and nothing else. Every diagnostic goes to
stderr. One stray byte on stdout would desynchronize the client's JSON-RPC
parser and end the session, so there is no such thing as a harmless
console.log on the startup or request path; test/stdio-entrypoint.test.ts
spawns a real server and asserts it.
Arguments that fail a tool's schema are rejected by the MCP SDK before any handler runs, so they return an error to the caller but produce no audit event — the execution context that would issue one is never opened. Every call that reaches a tool is audited.
Body size and concurrency (dormant HTTP runtime only)
None of this applies to the shipped server. It describes the dormant HTTP
runtime, which no CLI path reaches — see
the enterprise release boundary
— and binds only someone embedding this package and calling createHttpRuntime
directly. Over stdio there is no request-body limit and no admission ceiling.
Request body size and concurrency trade directly against each other under the 512 MiB admission ceiling:
maxBodyBytes | Highest concurrency that starts | Effect |
|---|---|---|
| 1 MiB (shipped default) | 2 | 416 MiB budgeted; the intended configuration |
| 1.75 MiB | 2 | 512 MiB — exactly at the ceiling |
| 2 MiB | 1 | Single-flight: every tool call serializes |
| 5.75 MiB | 1 | the last value that starts at all |
| above 5.75 MiB | none | startup fails at any concurrency |
Two failure modes are worth knowing:
- At 2 MiB and above the server is single-flight. Concurrency 2 no longer fits, so the runtime can only start at 1 and every tool call queues behind every other one. There is no warning and no log line — it presents as "the server got slow", and one large upload blocks every other tool for its duration. Nothing connects the cause to the effect.
- Above 5.75 MiB the server refuses to start. A constructor
throw, not a clamp. The message namesmaxConcurrentRequestsandmaxBodyBytesbut gives neither the ceiling, the arithmetic, nor a working value; the table above is the way forward.
maxBodyBytes is not operator-configurable. src/http-entrypoint.ts
builds the request policy with only allowedHosts and allowedOrigins, so the
limit is always 1 MiB and no environment variable changes it.
Code search
sn_codesearch {search_term, table?, field?, limit?, offset?} finds records
whose script contains the text, in the business rules, script includes, UI
scripts, client scripts, scripted REST operations, ES modules and ATF step
scripts of the instance. Each row
is {table, table_label, sys_id, name, snippet, line}: snippet is about 200
characters of the script centred on the first match (... marks a cut) and
line is the line that match is on. The comparison is the instance's
case-insensitive LIKE; if the text holds no literal match for the term, the
snippet is the head of the script and the row has no line.
- One table or all. With
table, one table is searched (andfieldcan name another field of it, such asname). With none, every code table the profile may read is searched, and the tables left out are named in a warning (Not searched, because this profile does not allow sn_codesearch to read them: sys_script, sys_ws_operation. To include one, run servicenow-mcp-setup grant --profile <profile> --read <table> --tools sn_codesearch.). A table is left out when the table policy does not bindsn_codesearchto it or the field policy does not let the profile read its script field. The call fails only when none can be read, and the error says why. - ES modules are
sys_module: the script is itscontentcolumn and a row is named by itspath, because the table has noname. A profile reads it once the table policy allows it:servicenow-mcp-setup grant --profile dev --read sys_module, or a read wildcard. It is cached by default like the other code tables, andfields=allreadscontent. A defaultsn_queryof it listssys_id,pathandsys_updated_on.sys_moduleis a built-in system table (the 24th), so a"*"entry in the field policy does not narrow it: a profile whose"*"entry limitsreadableand that can readsys_modulenow readscontent, where it did not before. To narrow it, name it infieldPolicy("sys_module": { "readable": ["sys_id", "path"] }). - ATF step scripts are searched with
table: "sys_atf_step". A step's script is not a column of the step but the value of its script input, a row ofsys_variable_value. The search reads only the rows whosedocumentissys_atf_stepand whosevariableends withscript, a condition fixed in the server: no argument can widen it to another table's variables, andfieldis refused. Each result is the step (sys_idis the step's), named<test name> > step <order>whereorderis the step's own order value, and the steps and then their tests are read by id to say so. Three tables are read, so the profile needs read onsys_variable_value,sys_atf_stepandsys_atf_test, each bound tosn_codesearch:servicenow-mcp-setup grant --profile dev --read sys_variable_value,sys_atf_step,sys_atf_test(or--tools sn_codesearchto bind only this tool:sys_variable_valuealso holds other tables' variable values, which that grant does not let this tool search).grant --atfbinds those tables tosn_atf_authoronly, so a profile that has it adds this grant on top. A search with notableincludes ATF step scripts when all three are held and namessys_atf_stepin the warning when they are not. These tables are not in the default cache list: the reads go straight to the instance. - A page is shared among the tables. A search of several tables takes turns:
each table's first match (script includes first, then business rules, UI
scripts, client scripts, scripted REST operations, ES modules), then each
table's second,
and so on, each table in
sys_idorder. No table crowds the others off page 1, and the order depends only on the data, sooffsetandnext_offsetpage through it exactly. A table with few matches leaves its share to the others. - Large pages degrade, they do not fail. A script can be hundreds of
kilobytes, so a page of them does not fit one response. A search of one table
with
limit49 or less reads the scripts with the rows, in one request (and falls back to the two steps below if that page passes the cap). A larger page, or a search of several tables, first finds the rows without their scripts and then reads the scripts of the rows it returns, 50 at a time, narrowing a batch that is still too large. One search spends at most 12 such requests and 8 MiB, and only for the rows one response can hold (about 280); when that is spent, the remaining rows keep an emptysnippetand a warning says how many (lowerlimit). A script too large to read even on its own gives its row an emptysnippetandnote: "script too large to preview"; read it withsn_get. If the rows alone pass the response cap, the error says the response was too large and to lowerlimitoroffset. - The scripts are still field-policy readable fields. The search reads the
identifier, the name and the searched field of each table, each subject to the
profile's field policy, and the sensitive-name rules apply to
field.
Metadata cache
Stable ServiceNow metadata reads are cached per instance and credential identity
for 24 hours by default. The default cached table patterns are
sys_glide_object, sys_dictionary, sys_db_object, sys_app, sys_plugins,
sys_metadata*, sys_flow*, and the six code tables sn_codesearch
searches: sys_script, sys_script_include, sys_ui_script,
sys_script_client, sys_ws_operation, and sys_module. A repeated code search or
sn_query page on those tables is served from the cache while the table's
watermark is unchanged. Set metadataCache.ttlMs and
metadataCache.tables on a file-backed profile, or SN_METADATA_CACHE_TTL_MS
/ SN_METADATA_CACHE_TABLES for the explicit environment profile; a table
list you set replaces the default list, so name the code tables in it to keep
caching them. sn_query, sn_get, and sn_schema accept force_recache: true
to refresh metadata; sn_codesearch has no such flag, so a change the
watermark cannot see shows there after at most one TTL. A cold sn_get of a
code-table record costs two requests (the watermark, then the record), and
sn_batch and sn_aggregate reads are never cached. Memory is bounded: a
response over 512 KiB is not cached, one credential scope keeps at most 32 MiB
and the whole cache 128 MiB, evicting the least recently used first. Cached
code-table entries hold full script bodies, which can contain hard-coded
credentials, in process memory (never on disk) for up to the TTL; to keep them
out, set metadataCache.tables or SN_METADATA_CACHE_TABLES to
sys_glide_object,sys_dictionary,sys_db_object,sys_app,sys_plugins,sys_metadata*,sys_flow*.
Freshness is checked against the instance, in every auth mode. Before each
fetch the cache reads a watermark in one small request: the table's row count
(X-Total-Count) and its newest row by sys_updated_on, as ServiceNow stores
it (UTC). A cache hit is served only while a new read of that watermark still
matches. Inserts and deletes change the count, and inserts and updates change
the newest row. Both sides of the comparison come from the instance, so the
session timezone, the date format, and clock skew between this host and the
instance play no part, and no user lookup is needed. Basic, OAuth (password or
client_credentials), and API-key profiles all cache the same way. The only
access it needs is the ServiceNow read permission of the user the credential
runs as, on the cached table itself; no tableAccess change is needed.
The honest tradeoff: the cache only ever saved payload bytes, never round
trips — a cache hit still costs one watermark read, and a miss costs one extra.
A tool call reads each table's watermark once, however many times it reads the
table, until the call writes. A hierarchy walk reads sys_db_object once for
the whole chain. An empty table caches like any other.
Small responses are not cached. A hit costs a round trip about the size of
a plain read, so a response under 32 KiB (serialized body) saves nothing and is
not kept. The first read of such a selector costs the watermark and the read,
as before; the server then remembers that selector as small, for one TTL, and
reads it again in a single request with no watermark. If a later read of it
comes back at 32 KiB or more, it is cached from the next read on. Large reads,
such as script bodies, are cached and checked exactly as above, and
force_recache: true still reads the watermark and refreshes. The memory is
per credential scope, holds at most 512 selectors (least recently used out),
and costs no cached bytes. A call that read a small selector this way reports
miss. On a table whose watermark is slow (sys_dictionary on a large
instance: about 0.5 s against a 0.1 to 0.2 s read in one measurement) even a
large read may be faster uncached; the threshold is a size, not a time. A
profile's metadataCache.smallReadBytes sets the threshold (0 caches every
response; at most 512 KiB).
Seeing what the cache did. Every successful response carries two optional
fields in structuredContent.metadata. cache says how the call's cacheable
reads were served: hit (all from the cache), miss (from ServiceNow: nothing
cached yet, the watermark moved, the entry expired, the table could not be
cached just then, or the response is small and not kept), bypass (a force_recache: true refresh), or mixed (the
call made several cacheable reads with different outcomes, such as an
sn_codesearch with no table over the code tables). It is absent when
the call read no cache-eligible table. timing is { total_ms, upstream_ms, watermark_ms, field_types_ms } in whole milliseconds, measured wall-clock:
total_ms is the whole tool call; upstream_ms is the time during which at
least one request to ServiceNow other than a watermark read was in flight
(retry waits included); watermark_ms is the same for the cache's watermark
reads; field_types_ms is the whole field-type lookup that runs before a
field-policy tool (the memo check, its reads, and a retry with its pause), 0
when the call made none, and its reads are not counted in upstream_ms. Overlapping
requests are counted once, not summed, so each figure is at most total_ms,
though the two can overlap each other and add up to more than it. A hit reports
upstream_ms: 0 and the watermark round trip it still costs. Callers that
share a credential share cache warmth (several profiles on one credential, or
several HTTP clients on one profile), so cache: "hit" can reflect another
caller's earlier read made with the same credential. Both fields hold only
numbers and those four words, and appear whether or not the cache is on
(timing always, cache only when a cacheable read happened). Only the server
sets them; a tool cannot supply its own. Each tool's outputSchema grows by
about 385 characters for them.
If a table's watermark cannot be used, its reads go straight upstream, without
a watermark request, for a while: 15 minutes when the cause persists (an
incomplete or future-dated watermark, a 403 or 404), 30 seconds when it may not
(429, 5xx, timeouts, network), never longer than the TTL. A table whose newest
row is dated after the instance's own clock is one of these: that row would
stay the newest however many others were updated. Entries cached earlier are
kept and serve again once the table is cacheable, and force_recache: true
asks again at once.
What the watermark can miss. An update within the same second as the stored
watermark, to a row other than the newest, and a write that skips the system
fields (autoSysFields(false)) leave it unchanged. Such a change shows within
one TTL — up to 24 hours at the default. Lower SN_METADATA_CACHE_TTL_MS or
pass force_recache: true to see it sooner. sn_batch is not exposed to these
gaps: it looks up the records it will update or delete on the instance on every
run, never in the cache, even on a cached table.
sn_schema results are also kept for 5 minutes per profile, credential
identity, and effective policy, so a repeat call costs no request at all. They
are not revalidated in that window; force_recache: true refreshes them, and
schemaCacheTtlMs / SN_SCHEMA_CACHE_TTL_MS (up to 1 hour) changes the window.
Paging when a response is cut to size
A read that does not fit max_response_bytes (or, for a result with more than
1,000 rows, the record limit) is cut by dropping whole rows from the tail, so
the rows that come back are always a prefix of the page you asked for. For the
list tools, has_more and next_offset count the rows that were dropped:
| Field | Meaning |
|---|---|
record_count | Rows in results. |
truncated, dropped_records | sn_query sets them when rows were dropped for size, and says how many; every list tool reports the same in metadata.truncation. |
has_more | True when rows were dropped for size or rows exist past the page: rows exist that this response did not contain. A response that came back empty because its rows were too large says has_more: true, not "no results". |
next_offset | offset + record_count: the first row not returned. Following it re-reads the dropped rows before anything later, so a client that only follows next_offset sees every row exactly once. |
When no row fit, there is nothing to continue after, so next_offset is
left out and metadata.pagination.recovery is
adjust_request_and_retry_same_offset: has_more: true with no next_offset
means the request must change (fewer fields, a lower limit, or a higher
max_response_bytes; sn_get reads one row). The hint says which.
This holds for sn_query, sn_syslog, sn_schema, sn_relationships,
sn_codesearch, sn_discover, sn_attach (list), sn_atf and sn_aggregate
(grouped), whose offset is a row offset into the rows they return. Any other
collection result that is cut to size reports has_more: true with no
next_offset.
A page that lost no rows to size is unchanged: has_more and next_offset
come from the row after the page, and next_offset is offset + limit.
A client that follows next_offset should also pass the limit the hint names
(continue offset=8 limit=8): at the original limit each page asks
ServiceNow for that many rows and the cut drops most of them again, so the same
rows are fetched many times over.
Before this change next_offset after a cut page was offset + limit, which
skipped the dropped rows, and a cut last page reported has_more: false with
record_count: 0.
The sn_query hint gives values you can use. For example
Dropped 14/22; continue offset=8 limit=8; retry offset=0 with fields="sys_id,name" or max_response_bytes=1500 (fits the next row) or max_response_bytes=31500 (fits all 22).
continue offset=8 limit=8isnext_offsetand the number of rows that fit: page on with thatlimitand nothing is dropped again.retry offset=0 with ...re-reads the whole page in one response, with fewer fields or a larger budget. The two budgets are different numbers, and each says what it buys.max_response_bytes=1500 (fits the next row)holds one more row than this response did, so a retry with it returns about one more row;max_response_bytes=31500 (fits all 22)holds every row of the page. Both are measured from the response itself (the rows plus the envelope's own metadata) and rounded up. The page figure is left out when it would be more than the 1,000,000-byte maximum (or themaxResponseBytesof the raw-read rule that approved a rawquery, when that is lower) and when only one row was dropped, since the next row is then the rest of the page. When even the next row would be more than that maximum, the hint says the next row exceeds it, names it, and offers only fields andsn_get. It never names a budget the policy would deny.fields=...appears when it helps: the table's short default list for a read of the defaults or ofall, or your own list without its large fields (for examplescript) when you chose one. It only ever names fields your profile may read, and never a sensitive one. A list with nothing large in it gets thelimitand the budget instead.response_format="concise"is offered to adetailedread.- When no row fit, there is no
continueclause and nolimit: only the retry options andsn_get.
Unrestricted field selection (fields=all, response_format=detailed)
Both resolve to the profile's readable set for the table. Where the field
policy narrows that set, they request exactly the listed fields and read no
dictionary rows; the rest of this section applies when the readable set is
every field. That wildcard selection used to drop sysparm_fields entirely,
so ServiceNow returned every column and a wide table could breach the 1 MiB
cumulative upstream cap and fail the call outright. It is now bounded to at
most 100 columns.
The cap bounds the upstream request, not the response — truncating after
receipt would not help, because the bytes have already crossed the wire and
already breached the limit. Columns are resolved from sys_dictionary, walking
super_class so an extended table contributes its inherited fields. Ordering is
deterministic: the table's curated default projection first in its declared
order, then every remaining column alphabetically. Defaults lead so a capped
result stays useful; alphabetical afterwards because dictionary row order is not
stable across instances. Every failure path falls back to the table's bounded
default projection, never to dropping sysparm_fields.
sn_query reports truncation through its hint field. sn_get will carry the
same notice shortly.
Two behavior changes worth stating plainly, because they change what a caller gets back:
- Journal fields are now returned.
commentsandwork_notesare included in the resolved set forfields=allanddetailedwherever the profile can read them. See Journal content and field selection. - Sensitive-looking field names are excluded from the resolved set entirely.
A name matching the sensitive-field pattern is never requested, rather than
being requested and scrubbed on arrival. Under the old wildcard behavior the
value crossed the wire and was then removed; naming it in
sysparm_fieldswould have pulled it over deliberately, which is worse.
Journal content and field selection
Journal content on incident — comments (customer-visible) and work_notes
(internal) — is readable through fields=all, response_format: "detailed", an
explicit fields=comments, and sn_schema. The default projection still
excludes it, so an ordinary sn_query or sn_get does not return it.
Stated as a fact rather than a warning: journal content on real instances
routinely contains customer PII, so asking for all fields on incident returns
customer-visible commentary along with everything else. Operators granting
incident reads to an agent should know that. If that is not wanted, grant a
narrower read via the field policy rather than relying on the default
projection, since the caller chooses fields.
Attachment payloads
sn_attach never reads from or writes to host filesystem paths. Uploads use a
safe leaf file_name plus content_base64; downloads return
content_base64, file_name, content_type, and size_bytes. Download also
requires the owning table and record sys_id, which are policy-authorized
and verified against attachment metadata before any bytes are returned.
Size limit: 10 MiB decoded, and that is the only one. The stdio transport
frames messages by newline with no size bound, so the tool's own limits are
what apply — 10 MiB of decoded bytes for an upload, and a separate 10 MiB raw
budget for a download. The tool's content_base64 schema description carries
the authoritative figure.
The ~760 KiB practical ceiling documented before 2.1 came from the HTTP body limit, which no longer applies: the client and server share a pipe, not an envelope. Base64 still inflates a file by about a third in the message itself, so a 10 MiB attachment is roughly a 13.3 MiB JSON frame — large, but the transport will carry it.
Treat sn_attach as suitable for logs, configs, screenshots, and documents
rather than bulk transfer; a very large frame still costs memory in both the
client and the server, and ServiceNow's own UI or a dedicated integration is a
better path for bulk file movement.
Table access policy
2.0 denies every ServiceNow table by default. Table access is selected per
profile, not from a process-wide implicit default. File-backed profiles define
tableAccess in ~/.servicenow-mcp/config.json; the explicit SN_PROFILE_NAME
environment profile maps the SN_ALLOWED_* variables into that one profile only
when no profile file exists. If a profile has no table rules, it denies all.
Write the rules with the CLI rather than by hand — it validates the result with the same loader the server uses at request time:
servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
servicenow-mcp-setup grant --profile dev --read cmdb_ci --tools sn_query,sn_relationships
servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task
servicenow-mcp-setup grant --profile dev --flows # sn_flow_view's 15 tables, bound to sn_flow_view only
A read grant without --tools binds sn_query, sn_get, sn_aggregate,
sn_schema and sn_codesearch to each table it names. sn_codesearch is
authorized per code table it searches (sys_script, sys_script_include,
sys_ui_script, sys_script_client, sys_ws_operation, sys_module), so
servicenow-mcp-setup grant --profile dev --read sys_script_include lets that
profile search script includes. A search with no table searches the code tables
the profile may read and names the others in a warning; it fails only when the
profile may read none of them. On any other table the binding is inert. A profile written before
sn_codesearch was a default keeps the tool list it was saved with and is not
rewritten: re-run the same grant --read <code table> to add it, or pass
--tools sn_codesearch to add only that tool. Neither removes a tool. The
profile's field policy still decides the script field: sn_codesearch is
denied on a code table whose script field is not readable, exactly as sn_query
is for that field (in a search with no table that table is left out and named
in the warning instead).
A call the table policy refuses says which table and which tool were refused, and
whether the table is missing from the profile or only the tool is, and it gives
the command that lifts it: Table access was denied by policy: "sys_script_include" is granted to this profile, but not for sn_codesearch. To allow it, run: servicenow-mcp-setup grant --profile <profile> --read sys_script_include --tools sn_codesearch. --tools adds to the tools a table already has, so that command
removes nothing. The message names only the table and the tool of that call,
never the rest of the profile's rules.
Allowlist entries may be exact table names or the literal * to allow every
table for that operation. Table names are trimmed, lowercased, deduplicated,
and must be valid ServiceNow identifiers.
tableAccessis the sole table-level authority. There is no longer a built-in list of tables the server refuses unconditionally. A profile that grants a table gets it, subject only to ServiceNow's own per-user ACLs — so a grant ofsys_script,sys_user_role, or a credential table is honored. Writingsys_scriptis server-side script execution under the integration account. Least privilege now lives entirely in the grant and in the roles you give that account; grant the narrowest set that does the job, and prefer an account whose ServiceNow roles cannot reach what the grant does not need.
| Variable | Required | Default | Description |
|---|---|---|---|
SN_ALLOWED_READ_TABLES | ❌ | deny all | Tables permitted for read operations on the explicit SN_PROFILE_NAME environment profile only. Use * to allow every readable table except sys_audit, sys_journal_field, sys_history_line, sys_audit_delete, sys_attachment_doc and sys_email, which are covered only when named (see Field policy). |
SN_ALLOWED_WRITE_TABLES | ❌ | deny all | Tables permitted for create, update, incident journal append, delete, upload, and confirmed batch operations on the explicit SN_PROFILE_NAME environment profile only. Use * to allow every writable table except the same six named-only tables. Write permission never implies read permission. |
SN_TABLE_ACCESS_TARGETS | Required for exact allowlisted caller-addressable tables; optional with * | [] | Trusted JSON classification with table, exact permitted tools, kind (canonical, alias, view, or extension), literal closureComplete: true, and relatedTables: the target itself plus any backing or parent tables the operator declares. The loader checks that every related table has the target's operation permission; it does not derive the list from the instance, and the list grants no access. A self-only list is valid for a canonical target; alias, view and extension targets must name at least one backing table, and a view or alias should declare every table it reads, because it returns data from each of them whatever the list says. With *, omitted target entries use the wildcard operation grant; explicit target entries can still narrow tools and check their related tables. |
SN_FIELD_POLICY_DEFINITIONS | ❌ | no narrowing | Field policy for the explicit SN_PROFILE_NAME environment profile only, like the SN_ALLOWED_* variables. If ~/.servicenow-mcp/config.json exists, setting this variable stops startup; give those profiles their own fieldPolicy instead. The value is trusted JSON, at most 65,536 characters: either a table map keyed by table name or *, the same shape as a profile's fieldPolicy, or an object holding the profile keys (fieldPolicy, or readableTableFields / writableTableFields), not both. Each field set is a list of |
Frequently asked questions
What is OnlyFlows ServiceNow MCP Server?
Governed ServiceNow MCP: per-profile table and field policy, dry-run batches, activity events.
How do I install OnlyFlows ServiceNow MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. OnlyFlows ServiceNow MCP Server runs locally from the npm package @onlyflows/servicenow-mcp with the command npx -y @onlyflows/servicenow-mcp@2.4.0.
Is OnlyFlows ServiceNow MCP Server free and open source?
Yes. OnlyFlows ServiceNow MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does OnlyFlows ServiceNow MCP Server support remote (HTTP) connections?
No remote endpoint is listed for OnlyFlows ServiceNow MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does OnlyFlows ServiceNow MCP Server provide?
OnlyFlows ServiceNow MCP Server provides 26 tools, including sn_aggregate, sn_atf, sn_atf_author, and sn_atf_readiness. See the full tool list for descriptions and parameters.
How is OnlyFlows ServiceNow MCP Server's trust score calculated?
OnlyFlows ServiceNow MCP Server scores 70 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.