Skip to content

charish2108/ServiceNowMCPServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServiceNow MCP Server

A Model Context Protocol (MCP) server for ServiceNow that authenticates via SSO through a persistent browser bridge. Supports full CRUD operations on Incidents, Change Requests, catalog requests, and generic table queries.

Architecture

Claude Code / VS Code  <-->  mcpnow1.py (MCP server, stdio)
                                  |
                          snow_request.txt / snow_response.txt (file-based IPC)
                                  |
                            snow_auth.py (browser bridge)
                                  |
                          Playwright persistent browser context
                                  |
                          ServiceNow REST API (via XHR + CSRF token)
  • mcpnow1.py — MCP server that exposes tools and communicates with the bridge via file IPC
  • snow_auth.py — Persistent browser bridge that handles SSO login and makes authenticated API calls using XMLHttpRequest from within the browser context
  • The bridge runs in the background with no visible console window
  • Session cookies persist across restarts via Playwright's persistent browser profile

Prerequisites

  • Python 3.11+
  • Windows, macOS, or Linux (fully cross-platform)
  • Dependencies (install via pip install -r requirements.txt):
    • Playwright — Browser automation for SSO login
    • MCP SDK — Model Context Protocol framework
    • psutil — Process management (optional but recommended; falls back to platform-specific commands)
  • A ServiceNow instance that uses SSO authentication (Azure AD, Okta, etc.)

Configuration

Add the following to your MCP configuration file:

  • VS Code: %APPDATA%\Code\User\mcp.json
  • Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json
{
  "servers": {
    "servicenow": {
      "type": "stdio",
      "command": "C:/path/to/python.exe",
      "args": [
        "C:/path/to/ServiceNowMCPServer-master/mcpnow1.py"
      ],
      "env": {
        "SERVICENOW_URL": "https://your-instance.service-now.com",
        "SERVICENOW_USER": "Your Full Name",
        "SERVICENOW_ASSIGNMENT_GROUP": "Your Assignment Group Name"
      }
    }
  }
}

Environment Variables

Variable Required Description
SERVICENOW_URL Yes Your ServiceNow instance URL (e.g. https://company.service-now.com)
SERVICENOW_USER Yes Your full display name as it appears in ServiceNow (used to filter "assigned to me" and "created by me" queries)
SERVICENOW_ASSIGNMENT_GROUP No Your assignment group name (used by get_open_change_requests to filter by group)

First-Time Setup

  1. Install dependencies:
    pip install -r requirements.txt
    playwright install chromium
  2. Configure mcp.json as shown above
  3. Restart VS Code / Claude Desktop to load the new MCP server
  4. Run snow_login — a browser window will open for SSO authentication
  5. Complete your SSO login in the browser
  6. Once logged in, the browser hides itself and the bridge runs in the background
  7. You can now use any of the ServiceNow tools

Subsequent Sessions

The browser profile persists cookies across restarts. When you run snow_login again:

  • If the session is still valid, SSO is skipped automatically
  • If the session expired, the browser will show for re-authentication

Available Operations

Authentication

Tool Description
snow_login Open browser for SSO login and start the background bridge

Incident Operations

Tool Parameters Description
get_incident incident_number Get full details of a specific incident (e.g. INC0012345)
get_my_incidents Get latest incidents assigned to you
create_incident short_description, urgency?, category?, description? Create a new incident
update_incident incident_number, fields (JSON string) Update fields on an incident
add_comment_to_incident incident_number, comment, work_note? Add a comment or work note

Change Request Operations

Tool Parameters Description
get_change_request change_number Get full details of a change request (e.g. CHG0012345)
get_my_change_tickets Get change tickets assigned to you
get_my_created_change_tickets Get change tickets created by you
get_open_change_requests Get open CRs for your assignment group
create_change_request short_description, change_type?, priority?, description? Create a new change request
update_change_request change_number, fields (JSON string) Update fields on a change request
add_comment_to_change change_number, comment, work_note? Add a comment or work note

General Query Operations

Tool Parameters Description
query_table table, query?, fields?, limit? Generic query any ServiceNow table
get_user_info search Look up a user by name or email
get_my_requests Get your service catalog requests

Legacy / Test Tools

Tool Description
nowtest Verify the MCP server is running
nowtestauth Test authentication with a custom ServiceNow API
similarincidentsfortext Find incidents matching input text
similarincidentsforincident Find incidents similar to a given incident
getshortdescforincident Get short description for an incident number

Usage Examples

# Authenticate
snow_login

# Get your change tickets
get_my_change_tickets

# Get details of a specific incident
get_incident INC0012345

# Create an incident
create_incident "Database connection timeout on prod" urgency=1 category=Software

# Add a work note
add_comment_to_incident INC0012345 "Investigated — root cause is connection pool exhaustion" work_note=true

# Query any table
query_table cmdb_ci query="operational_status=1" fields="name,sys_class_name,operational_status" limit=20

Troubleshooting

Issue Fix
"Not logged in" error Run snow_login first
Browser doesn't appear for SSO Check snow_bridge.log in the project directory for errors
Bridge seems stuck Delete snow_ready.txt, snow_bridge.pid, and run snow_login again
API calls time out Verify SERVICENOW_URL is correct and accessible from your network
"SERVICENOW_URL not set" error Check your mcp.json env configuration

Files

File Purpose
mcpnow1.py MCP server — tool definitions and request routing
snow_auth.py Browser bridge — SSO login and authenticated API calls

Note: Additional files (snow_browser_profile/, snow_bridge.log, snow_bridge.pid, snow_ready.txt, etc.) are created automatically at runtime. These are transient/local and should not be committed — see .gitignore.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages