Version: 1.1.1
ServiceNow API Python Wrapper
This repository is actively maintained and will continue adding more API calls
This can run as a standalone MCP Server for Agentic AI!
Contributions are welcome!
All API Response objects are customized for the response call. You can get all return values in a parent.value.nested_value format, or you can run parent.model_dump() to get the table in dictionary format.
- Application Service
- Change Management
- CI/CD
- CMDB
- Import Sets
- Incident
- Knowledge Base
- Table
- Custom Endpoint
If your API call isn't supported, you can always run the standard custom API endpoint function to get/post/put/delete and endpoint
Usage:
OAuth Authentication
#!/usr/bin/python
# coding: utf-8
import servicenow_api
username = "<SERVICENOW USERNAME>"
password = "<SERVICENOW PASSWORD>"
client_id = "<SERVICENOW CLIENT_ID>"
client_secret = "<SERVICENOW_CLIENT_SECRET>"
servicenow_url = "<SERVICENOW_URL>"
client = servicenow_api.Api(url=servicenow_url,
username=username,
password=password,
client_id=client_id,
client_secret=client_secret)
table = client.get_table(table="<TABLE NAME>")
print(f"Table: {table.model_dump()}")
Basic Authentication
#!/usr/bin/python
# coding: utf-8
import servicenow_api
username = "<SERVICENOW USERNAME>"
password = "<SERVICENOW PASSWORD>"
servicenow_url = "<SERVICENOW_URL>"
client = servicenow_api.Api(url=servicenow_url,
username=username,
password=password)
table = client.get_table(table="<TABLE NAME>")
print(f"Table: {table.model_dump()}")
Proxy and SSL Verify
#!/usr/bin/python
# coding: utf-8
import servicenow_api
username = "<SERVICENOW USERNAME>"
password = "<SERVICENOW PASSWORD>"
servicenow_url = "<SERVICENOW_URL>"
proxy = "https://proxy.net"
client = servicenow_api.Api(url=servicenow_url,
username=username,
password=password,
proxy=proxy,
verify=False)
table = client.get_table(table="<TABLE NAME>")
print(f"Table: {table.model_dump()}")
Deploy MCP Server as a Service
docker pull knucklessg1/servicenow:latest
Modify the compose.yml
services:
servicenow-mcp:
image: knucklessg1/servicenow:latest
environment:
- HOST=0.0.0.0
- PORT=8004
ports:
- 8004:8004
Configure mcp.json
Recommended: Store secrets in environment variables with lookup in JSON file.
For Testing Only: Plain text storage will also work, although not recommended.
{
"mcpServers": {
"servicenow": {
"command": "uv",
"args": [
"run",
"--with",
"servicenow-api",
"servicenow-mcp"
],
"env": {
"SERVICENOW_INSTANCE": "https://www.servicenow.com",
"SERVICENOW_USERNAME": "user",
"SERVICENOW_PASSWORD": "pass",
"SERVICENOW_CLIENT_ID": "client_id",
"SERVICENOW_CLIENT_SECRET": "client_secret",
"SERVICENOW_VERIFY": "False"
},
"timeout": 200000
}
}
}
Installation Instructions:
Install Python Package
python -m pip install servicenow-api
Tests:
python ./test/test_servicenow_models.py