ServiceNow-MCP 智能数据交互器
一种模型上下文协议服务器,使人工智能代理能够通过自然语言交互访问和服务现在数据,允许用户搜索记录、更新它们和管理脚本。
服务介绍
ServiceNow MCP 服务器
这是一个与 ServiceNow 接口的 Model Context Protocol (MCP) 服务器,允许 AI 代理通过安全 API 访问和操作 ServiceNow 数据。此服务器使与 ServiceNow 的自然语言交互成为可能,从而更易于搜索记录、更新记录和管理脚本。
功能
资源
servicenow://incidents: 列出最近的事件servicenow://incidents/{number}: 按编号获取特定事件servicenow://users: 列出用户servicenow://knowledge: 列出知识文章servicenow://tables: 列出可用表servicenow://tables/{table}: 从特定表中获取记录servicenow://schema/{table}: 获取表的模式
工具
基本工具
create_incident: 创建新事件update_incident: 更新现有事件search_records: 使用文本查询搜索记录get_record: 按 sys_id 获取特定记录perform_query: 对 ServiceNow 执行查询add_comment: 向事件添加评论(客户可见)add_work_notes: 向事件添加工作笔记(内部)
自然语言工具
natural_language_search: 使用自然语言搜索记录(例如,“查找所有关于 SAP 的事件”)natural_language_update: 使用自然语言更新记录(例如,“更新事件 INC0010001 并说明我正在处理它”)update_script: 更新 ServiceNow 脚本文件(脚本包含、业务规则等)
安装
从 PyPI
pip install mcp-server-servicenow
从源代码
git clone https://github.com/michaelbuckner/servicenow-mcp.git
cd servicenow-mcp
pip install -e .
使用
命令行
使用 Python 模块运行服务器:
python -m mcp_server_servicenow.cli --url "https://your-instance.service-now.com/" --username "your-username" --password "your-password"
或者使用环境变量:
export SERVICENOW_INSTANCE_URL="https://your-instance.service-now.com/"
export SERVICENOW_USERNAME="your-username"
export SERVICENOW_PASSWORD="your-password"
python -m mcp_server_servicenow.cli
在 Cline 中配置
要将此 MCP 服务器与 Cline 一起使用,请在您的 MCP 设置文件中添加以下内容:
{
"mcpServers": {
"servicenow": {
"command": "/path/to/your/python/executable",
"args": [
"-m",
"mcp_server_servicenow.cli",
"--url", "https://your-instance.service-now.com/",
"--username", "your-username",
"--password", "your-password"
],
"disabled": false,
"autoApprove": []
}
}
}
注意: 确保使用安装了 mcp-server-servicenow 包的 Python 可执行文件的完整路径。
自然语言示例
搜索记录
您可以使用自然语言查询来搜索记录:
find all incidents about email
search for incidents related to network issues
show me all incidents with high priority
更新记录
您可以使用自然语言命令来更新记录:
Update incident INC0010001 saying I'm working on it
Set incident INC0010002 to in progress
Close incident INC0010003 with resolution: fixed the issue
管理脚本
您可以从本地文件更新 ServiceNow 脚本:
Update the ServiceNow script include "HelloWorld" with the contents of hello_world.js
Upload utils.js to ServiceNow as a script include named "UtilityFunctions"
Update @form_validation.js, it's a client script called "FormValidation"
身份验证方法
服务器支持多种身份验证方法:
- 基本身份验证:用户名和密码
- 令牌身份验证:OAuth 令牌
- OAuth 身份验证:客户端 ID、客户端密钥、用户名和密码
开发
先决条件
- Python 3.8+
- 具有 API 访问权限的 ServiceNow 实例
设置开发环境
# Clone the repository
git clone https://github.com/michaelbuckner/servicenow-mcp.git
cd servicenow-mcp
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
运行测试
pytest
贡献
欢迎贡献!请随时提交 Pull Request。
- Fork 仓库
- 创建你的功能分支 (
git checkout -b feature/amazing-feature) - 提交你的更改 (
git commit -m 'Add some amazing feature') - 将更改推送到分支 (
git push origin feature/amazing-feature) - 打开一个 Pull Request
许可证
本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。