ServiceNow MCP
About
ServiceNow MCP server: 65 tools over the full REST surface (Table, Aggregate, Attachment, Import Set, Batch, CMDB/IRE, Catalog, Change, Knowledge, Email) with script intelligence, flow tracing, ATF runs, multi-instance profiles and Mermaid diagrams.
Details
- Author
- leasstatt
- Categories
- Productivity, Automation, API, Database, Other
Jump to
Setup
Install ServiceNow MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/leasstatt/servicenow-mcp-ai
Follow the installation instructions in the repository README, then restart your MCP client.
servicenow-mcp-ai — ServiceNow MCP Server
Upgrading from 1.x?v2.0 makes writesplan-by-default:create/update/deleteand the other record-write tools return a non-mutating preview unless you passapply: true(or setSN_WRITE_MODE=applyto restore the v1 "execute immediately" behaviour). See theCHANGELOG→ 2.0.0 for the full migration note.
Contents:Quick demo·Features·Requirements·Setup·Configure credentials·Run / debug·Develop·Tools·Resources·Prompts·Project structure·Security notes·Project documentation·Support
Built and maintained in my own time — if it helps, aGitHub Sponsorstip keeps it going. FullSupportoptions are near the end.
Three things the platform makes hard, one call each. Point your MCP client at an instance (Setup) and ask:
1. "Where is this field actually used?"— every script, business rule, client script, UI policy/action and ACL that touches it, as JSON or a Mermaid graph. The IDE-gradefind usagesServiceNow has no button for:
// servicenow_where_used { "kind": "field", // "table" | "field" | "script" "name": "u_cost_center", "mermaid": true, // also render a reference graph }
2. "What runs when I save this record?"— the full automation chain in execution order (display → before → after → async business rules, then flows, workflows and notifications), each with its condition — a logical test that runsnothing:
// servicenow_trace_table_event { "table": "incident", "operation": "update", // insert | update | delete | query }
3. "What drifted between dev and prod?"— a Markdown diff of tables, columns, scripts (by SHA-256) and plugins between two configured profiles, with a CI-friendly exit code so a pipeline can block a risky deploy:
servicenow-mcp-ai drift dev prod # report on stdout; exit 1 on drift, 0 if clean
All three areread-onlyand work against any instance — including a free PDI — with the model and client of your choice.
- FullTable API: query, read, create, update and delete records onanytable, with encoded queries, field selection and pagination.
- Extra ServiceNow APIs:Aggregate(Stats),Attachment(list/upload/download/delete),Import Set,Batch(many REST calls in a single request), plus table/columnmetadata(sys_db_object,sys_dictionary).
- Process & plugin APIs:CMDB(class-aware CI CRUD + meta via IRE),Service Catalog(browse/order items),Change Management(typed creation + conflict detection) andKnowledge(article search). Plugin-scoped APIs report clearly when not active on the instance.
- Script intelligence: read and search the instance's own code (business rules, script includes, client scripts, UI policies/actions, scheduled jobs, transform/REST scripts, ACLs) and get a table's full automation picture — all read-only over the Table API.
- Flow tracing & code checking(Phase 8): deterministically trace what a table operation runs (flowspackage — business rules, flows, workflows and notifications, in order, with a Mermaid flowchart), read Flow Designer flows and run history, and lint scripts against a local rule set with an aggregate code-health report (codecheck). Run ATF tests via the CI/CD API (atf, opt-in, non-default — the run tools execute on the instance).
- Self-documentation: a local Markdown knowledge base (read/write/search) plus deterministic Mermaid generators (ER diagrams from references, record-lifecycle flowcharts from business rules) so the server builds durable, reusable context.
- Prompts: ready-made workflows (incident triage, change impact analysis, document a table) that orchestrate the tools.
- Tool packages: load only the tool groups you need viaSN_TOOL_PACKAGES(default profilecore;allenables everything).
- BasicorOAuth 2.0authentication over HTTPS; the password/token is never echoed back.
- Least-privilege controls: table allow/deny lists and a global read-only mode.
- Resilience: per-request timeout, retry with backoff andRetry-After, SSRF guard, and a result-size guard.
- MCPtool annotationsandresources, structured error payloads, and structured logging on stderr.
- Credentials in an env file (project,~/.config, orSN_ENV_FILE), updatable at runtime viaservicenow_set_credentials.
- Node.js 20+ (enforced:engines+ a runtime guard with a clear message; the project targets the version in.nvmrc).
Or run the published package directly, without cloning:
Register it with an MCP client (Claude Desktop, VS Code Chat, the Inspector…) by pointing the server command atnpx:
{ "mcpServers": { "servicenow": { "command": "npx", "args": ["-y", "servicenow-mcp-ai"] } } }
Claude Code plugin(zero-config — installs the server wired up):
/plugin marketplace add IvanBBaev/servicenow-mcp-ai /plugin install servicenow-mcp-ai
VS Code— install theServiceNow MCPextension from the Marketplace (code --install-extension ivanbbaev.servicenow-mcp-ai); it registers the server in Copilot Chat (agent mode) automatically, no manualmcp.json. Source:extension/.
Credentials are read from~/.config/servicenow-mcp-ai/.env(or real environment variables) — see below.
The fastest path is three lines of Basic auth — set these (in the env file or the real environment) and you are connected:
SN_INSTANCE=dev12345.service-now.com SN_USER=your.username SN_PASSWORD=your-password
Everything else is optional tuning; see the fullEnvironment variablesreference for the rest.
Past a quick try, prefer OAuth over a stored password.For anything shared or long-lived, run the one-timenpx servicenow-mcp-ai logininstead — it stores a refresh token, not your password. SeeConfigure credentials→OAuth 2.1.
Once the three variables are set, confirm the connection before you start:
- Run theservicenow_test_connectiontool — it reads onesys_userrecord and reportsok, HTTP status and latency.
- Runservicenow_check_capabilities— it previews which admin-restrictedsys_tables the connected user can actually read.
npx servicenow-mcp-ai doctor # checks credentials, reachability and capabilities
Credentials live in.envat the project root (git-ignored):
SN_INSTANCE=your-instance.service-now.com SN_USER=your.username@example.com SN_PASSWORD=your-password
SN_INSTANCEacceptsdev12345,dev12345.service-now.comor a fullhttps://URL.
You can also set or change them at runtime by calling theservicenow_set_credentialstool — the new values are written straight back to the env file.
The env file is resolved in this order:SN_ENV_FILE, then~/.config/servicenow-mcp-ai/.env(XDG) if present, then the project-root.env. A global/npxinstall therefore writes to your user config rather than intonode_modules. Real environment variables always take precedence over the file.
OAuth 2.1 (Authorization Code + PKCE) — recommended
Register anAuthorization CodeOAuth API endpoint in ServiceNow with a loopback redirect URL (e.g.http://localhost:53682/callback), setSN_OAUTH_CLIENT_ID(andSN_OAUTH_CLIENT_SECRETfor a confidential client), then run the one-time interactive login:
It opens the browser, you approve, and the obtainedrefresh tokenis stored in your env file. The server then runs non-interactively (refresh_token grant) — no password is ever stored. PKCE (S256) is always used.
The OAuth 2.0password grant (ROPC) is deprecatedin OAuth 2.1 and disabled on many instances; preferlogin.client_credentialsandrefresh_tokengrants remain supported for service accounts. See.env.example.
Every inbound REST auth method ServiceNow offers is covered:
All settings are read from.env(or the real process environment, which takes precedence). Only the first three are required; the rest are optional tuning knobs. See.env.examplefor a template.
Access is controlled ontwo independent axes, because a table restriction does not reach the plugin-backed APIs (Change, Catalog, Knowledge…). Guard both:
So denying thechange_requesttable still leaves the Change Management API (sn_chg_rest) able to read/write changes — thepackage axis is why it exists. SeeSecurity notesfor the full model (including how the Batch API obeys both axes).
List syntax:table lists (SN_TABLES_ALLOW/SN_TABLES_DENY) are comma-separated; package lists (SN_TOOL_PACKAGES,SN_PACKAGES_DENY,SN_PACKAGES_READONLY) accept commasorwhitespace. Surrounding spaces are trimmed in both, and table matching is case-insensitive — soSN_TABLES_DENY=Change_Request, sys_userworks.
- VS Code: open the Command Palette and start the server defined in.vscode/mcp.json, then use it from Chat.
- MCP Inspector:npm run inspector
- Directly:npm start
The publishedservicenow-mcp-aibinary (run it directly, or vianpx servicenow-mcp-ai) has three invocations. All connection settings come from environment variables / the env file (seeEnvironment variables); onlydrifttakes positional arguments.
loginoperates on the active profile (SN_ACTIVE_PROFILE, defaultdefault) and reads, for that profile:
- SN_INSTANCE—required; the target instance.
- SN_OAUTH_CLIENT_ID—required; client id of an Authorization Code OAuth API endpoint.
- SN_OAUTH_CLIENT_SECRET— optional; for a confidential client.
- SN_OAUTH_REDIRECT_URI— optional; loopback URL, defaulthttp://localhost:53682/callback. Must match the redirect registered on the endpoint.
- SN_OAUTH_SCOPE— optional; requested OAuth scope.
On success it writesSN_AUTH=oauth,SN_OAUTH_GRANT=refresh_tokenandSN_OAUTH_REFRESH_TOKENback to the env file (profile-prefixed when the profile is notdefault). The authorization URL is printed on stderr in case the browser does not open automatically.
drifttakes two positional profile names; each must resolve to a configured profile (SN_PROFILE_<NAME>_, or the bareSN_INSTANCE/SN_USER/SN_PASSWORDkeys fordefault). The Markdown report is written tostdout(capture it as a CI artifact); a one-line drift summary goes to stderr.
Compare two configured profiles andfail a pipeline on configuration drift:
servicenow-mcp-ai drift dev prod # report on stdout; exit 1 on drift, 0 if clean, 2 on error
npm run check # full gate: build, lint, format check, coverage-gated tests, prod audit npm test # unit tests only (node:test; needs a prior npm run build) npm run lint # ESLint (flat config + typescript-eslint) npm run format # format with Prettier
This table is generated from the tool registrations — edit the tool definitions insrc/tools/, then runnpm run docs:readme.
All tools carry MCP annotations (readOnlyHint,destructiveHint,idempotentHint) so clients can apply the right confirmation UX.
Tools are grouped into packages so you can expose only what a given client needs (fewer tools keep the model focused). SetSN_TOOL_PACKAGESto a comma/space separated list of profiles or package names:
- core(default) —table,schema,aggregate,attachment.
- all— every package below.
- Individual packages:table,schema,aggregate,attachment,importset,batch,catalog,change,knowledge,cmdb,scripts,flows,codecheck,docs,instance,email,atf.
The admin tools (servicenow_set_credentials,servicenow_get_status) are always registered, regardless of the active packages. Unknown names are ignored.servicenow_get_statusreports the resolvedenabledPackages.
# Only table + batch tools (plus the always-on admin tools) SN_TOOL_PACKAGES=table,batch
If you would rather not curate the list yourself, three named presets cover the common roles. The admin tools are always on, so they are not listed. Each preset also has a one-word alias —SN_TOOL_PACKAGES=reader|developer|admin— that expands to the same package set.
Thedeveloperpreset builds on thereaderset; thedocspackage includes the Mermaid diagram generators. Use the alias for brevity or spell the packages out to add or drop one.
Query the 5 most recent active incidents:
// servicenow_query_table { "table": "incident", "query": "active=true^ORDERBYDESCsys_created_on", "fields": ["number", "short_description", "priority", "state"], "limit": 5, }
// servicenow_create_record { "table": "incident", "fields": { "short_description": "Printer on 3rd floor is down", "urgency": "2", "impact": "2", }, }
// servicenow_set_credentials { "instance": "dev98765.service-now.com", "user": "admin", "password": "••••••", }
Read-only metadata is also exposed as MCP resources, so clients can attach it declaratively instead of calling a tool:
Ready-made workflows are exposed as MCP prompts; they orchestrate the tools and insist on reading real values from the instance:
. ├── .env # credentials (git-ignored; or ~/.config/servicenow-mcp-ai/.env) ├── .env.example # template ├── .github/workflows/ # CI: build + lint + test ├── .vscode/mcp.json # VS Code MCP server registration ├── eslint.config.js # ESLint flat config ├── .prettierrc.json # Prettier config ├── src/ │ ├── index.ts # bootstrap: load env, register, connect stdio │ ├── registry.ts # registers all tool groups │ ├── resources.ts # MCP resources (status, tables, schema, docs) │ ├── prompts.ts # MCP prompts (triage, change impact, document table) │ ├── http.ts # shared REST client (auth, retry, SSRF) │ ├── auth.ts # Basic + OAuth 2.0 providers │ ├── host.ts # host resolution + SSRF guard │ ├── policy.ts # table allow/deny + read-only guards │ ├── settings.ts # numeric env settings │ ├── logging.ts # structured stderr logger │ ├── result.ts # tool results + structured errors │ ├── servicenow.ts # Table API client │ ├── config.ts # env file read/write + location │ ├── api/ # aggregate, attachment, import set, batch, catalog, change, knowledge, cmdb, scripts, diagrams, docs, meta │ └── tools/ # tool registration per API group ├── test/ # node:test unit + mock-fetch tests └── build/ # compiled output (after npm run build)
Note on names:the npm package and the GitHub repository are bothservicenow-mcp-ai(the unscopedservicenow-mcpwas already taken on npm); the local working folder isservicenow-mcp. The difference is cosmetic and does not affect the build or runtime.
- The env file is git-ignored — do not commit real credentials.
- The env file is writtenowner-only (0600)— it holds a plaintext password.
- The server uses the stdio transport and only logs tostderr; secrets and raw encoded queries are never logged.
- The password/token is never returned by any tool.
- Hosts are restricted: withoutSN_ALLOWED_HOSTS, only*.service-now.cominstances are contacted (internal/loopback always blocked), so a redirected or mistyped host cannot silently receive credentials. SetSN_ALLOWED_HOSTSto opt in a custom or sovereign-cloud domain.
- PreferOAuth 2.0over Basic where possible (SN_OAUTH_CLIENT_ID).
- Apply least privilege withSN_TABLES_ALLOW/SN_TABLES_DENYandSN_READONLY=truefor read-only deployments.
- Table policy does not cover plugin APIs.SN_TABLES_DENY=change_requestblocks the Table API path, but the Change Management API (sn_chg_rest) can still read/write changes. To restrict the plugin-backed surfaces useSN_PACKAGES_DENY(drop the whole package) orSN_PACKAGES_READONLY(register only its read tools). The Batch API obeys both axes too: a sub-request to a denied package's path is refused, and writes to a read-only package are blocked — a batch cannot be used to bypass the package policy.
This project is built and maintained in my own time. If it saves you or your team time, please consider supporting its continued development — sponsorship directly funds new tools, bug fixes and keeping pace with ServiceNow's REST surface.
- GitHub Sponsors— one-off or recurring, with no platform fee taken out (the preferred option).
- Ko-fi— quick one-off support; it also acceptsPayPal, so it's the fallback for anyone without a GitHub account.
- Donate (Donatree)— a no-account donation page (card, PayPal and more) for a one-off tip.
servicenow-mcp-aiis an independent, community-built project. It isnot affiliated with, endorsed by, or sponsored by ServiceNow, Inc.
"ServiceNow", the ServiceNow logo, "Now", and related marks are trademarks or registered trademarks of ServiceNow, Inc. in the United States and other countries. They are used in this project's name and documentationonly nominatively— to identify the platform this software interoperates with — and no affiliation or endorsement is implied. All other product names and marks are the property of their respective owners.
This project is licensed under theMIT License; that license covers the source code and does not grant any rights to use the ServiceNow trademarks.
MCP Server for Kingdee K3Cloud (金蝶云星空) — one of the most widely used ERP systems in China. Connects AI assistants (Claude Desktop, Cursor, Cline, Cherry Studio, etc.) to Kingdee ERP via natural language.
Generate documents, process PDFs, and manage e-signature workflows using the PDFGate API.
Mail real letters from agents: PDF → checkout → status.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.


