ServiceNow MCP Server
Enables Claude to interact with ServiceNow instances for incident management, knowledge base search, and JWT authentication.
README
ServiceNow MCP Server
A Model Context Protocol (MCP) server that enables Claude to interact with ServiceNow instances. This server provides tools for querying incidents, searching knowledge base articles, and retrieving specific ServiceNow data.
Features
- 🎫 Incident Management: Query and retrieve ServiceNow incidents with various filters
- 📚 Knowledge Base: Search and retrieve knowledge base articles
- 🔍 Specific Article Lookup: Get detailed information for specific KB articles
- 🔧 Connection Testing: Verify ServiceNow connectivity
- 🔐 JWT Authentication: Secure token-based authentication with automatic refresh
- 🛠️ Token Management: Generate, validate, and refresh JWT tokens
- 📊 Comprehensive Logging: Detailed logging for troubleshooting
Prerequisites
- Python 3.8 or higher
- ServiceNow instance with API access
- Claude Desktop application
Installation
-
Clone or navigate to the project directory:
cd /Users/vayyagari/PycharmProjects/snow_mcp_server_gd -
Activate the virtual environment:
source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
Configuration
1. ServiceNow Authentication Configuration
The server supports two authentication methods:
JWT Authentication (Recommended)
Create a .env file in the project root:
# Copy the template file
cp env_template.txt .env
# Edit with your actual credentials
nano .env
Initial Setup with Username/Password:
SERVICENOW_INSTANCE_URL=https://your-instance.service-now.com
SERVICENOW_USERNAME=your_username_here
SERVICENOW_PASSWORD=your_password_here
LOG_LEVEL=INFO
Production Setup with JWT Tokens:
SERVICENOW_INSTANCE_URL=https://your-instance.service-now.com
SERVICENOW_JWT_TOKEN=your_jwt_access_token_here
SERVICENOW_REFRESH_TOKEN=your_jwt_refresh_token_here
JWT_SECRET_KEY=your_secure_secret_key_here
LOG_LEVEL=INFO
2. Claude Desktop Configuration
Option 1: Environment Variables in Claude Config
Update your Claude Desktop configuration file with the server details and credentials:
Location: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
{
"mcpServers": {
"servicenow": {
"command": "python",
"args": ["/Users/vayyagari/PycharmProjects/snow_mcp_server_gd/server.py"],
"env": {
"SNOW_INSTANCE_URL": "https://your-instance.service-now.com",
"SNOW_USERNAME": "your_username_here",
"SNOW_PASSWORD": "your_password_here"
}
}
}
}
Option 2: Using .env file (Recommended)
Install python-dotenv and modify the server to load from .env:
{
"mcpServers": {
"servicenow": {
"command": "/Users/vayyagari/PycharmProjects/snow_mcp_server_gd/.venv/bin/python",
"args": ["/Users/vayyagari/PycharmProjects/snow_mcp_server_gd/server.py"],
"cwd": "/Users/vayyagari/PycharmProjects/snow_mcp_server_gd"
}
}
}
Usage
Starting the Server
The server will start automatically when Claude Desktop connects to it. You can also test it manually:
# Activate virtual environment
source .venv/bin/activate
# Run the server
python server.py
Available Tools
ServiceNow Data Tools
1. Get ServiceNow Incidents
# Example usage in Claude:
get_servicenow_incidents({
"state": "New",
"priority": "1",
"limit": 10
})
2. Search Knowledge Base
# Example usage in Claude:
search_knowledge_base({
"search_term": "password reset",
"limit": 5
})
3. Get Specific Knowledge Article
# Example usage in Claude:
get_knowledge_article({
"article_id": "KB0010001"
})
4. Test Connection
# Example usage in Claude:
test_connection()
JWT Authentication Tools
5. Generate JWT Token
# Generate initial JWT tokens using username/password
generate_jwt_token({
"username": "your_username",
"password": "your_password",
"instance_url": "https://your-instance.service-now.com"
})
6. Validate JWT Token
# Validate and get information about a JWT token
validate_jwt_token({
"token": "your_jwt_token_here"
})
7. Refresh JWT Token
# Generate new access token using refresh token
refresh_jwt_token({
"refresh_token": "your_refresh_token_here"
})
8. Get JWT Token Info
# Get token details without full validation
get_jwt_token_info({
"token": "your_jwt_token_here"
})
JWT Authentication Workflow
Setting Up JWT Authentication
-
Initial Setup (First Time)
# Set up initial credentials in .env SERVICENOW_INSTANCE_URL=https://your-instance.service-now.com SERVICENOW_USERNAME=your_username SERVICENOW_PASSWORD=your_password -
Generate JWT Tokens
# Use Claude to generate tokens generate_jwt_token({ "username": "your_username", "password": "your_password" }) -
Update Configuration for Production
# Update .env with generated tokens SERVICENOW_JWT_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... SERVICENOW_REFRESH_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... # Optional: Remove username/password for security # SERVICENOW_USERNAME= # SERVICENOW_PASSWORD= -
Token Management
- Tokens expire automatically (default: 24 hours for access tokens)
- Use
validate_jwt_token()to check token status - Use
refresh_jwt_token()to renew expired tokens - Use
get_jwt_token_info()to inspect token details
JWT Security Best Practices
- ✅ Use environment variables for token storage
- ✅ Rotate tokens regularly using refresh functionality
- ✅ Set strong JWT secret keys in production
- ✅ Monitor token expiration and refresh proactively
- ❌ Never commit tokens to version control
- ❌ Don't share tokens between environments
- ❌ Avoid logging tokens in production
Troubleshooting
Common Issues
-
"Claude is not connecting"
- Verify Claude Desktop configuration file path and syntax
- Check that Python path in config matches your virtual environment
- Ensure all credentials are correctly set
-
ServiceNow Authentication Errors
- JWT Token Issues:
- Verify JWT token hasn't expired using
validate_jwt_token() - Refresh expired tokens using
refresh_jwt_token() - Check JWT secret key is set correctly
- Verify JWT token hasn't expired using
- Username/Password Issues:
- Verify your ServiceNow credentials in
.envfile - Check that your ServiceNow user has API access permissions
- Confirm the instance URL format (should include https://)
- Verify your ServiceNow credentials in
- JWT Token Issues:
-
Module Import Errors
- Ensure virtual environment is activated
- Install all requirements:
pip install -r requirements.txt - Check that
gd-servicenow-apiis properly installed
-
Permission Denied Errors
- Ensure the server.py file is executable
- Check file permissions:
chmod +x server.py
Debug Mode
Enable debug logging by setting in your .env file:
LOG_LEVEL=DEBUG
Testing the Server
Test the server connection manually:
# Activate environment
source .venv/bin/activate
# Test the server
python -c "import asyncio; from server import test_connection; print(asyncio.run(test_connection()))"
Development
Project Structure
snow_mcp_server_gd/
├── .venv/ # Virtual environment
├── server.py # Main MCP server
├── requirements.txt # Python dependencies
├── claude_desktop_config.json # Claude configuration example
├── .env.example # Environment variables template
└── README.md # This file
Adding New Tools
To add new ServiceNow tools:
- Define a new Pydantic model for request validation
- Create a new
@server.tool()decorated function - Import and use appropriate ServiceNow API functions
- Handle errors and return structured responses
Security Notes
- Never commit
.envfiles with real credentials to version control - Use environment variables or secure credential management
- Ensure ServiceNow user has minimal required permissions
- Consider using OAuth or certificate-based authentication for production
Support
- Check ServiceNow API documentation for field names and query options
- Review MCP protocol documentation at https://modelcontextprotocol.io/
- Enable debug logging for detailed error information
License
This project is licensed under the MIT License.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。