ServiceNow MCP服务器

一个与ServiceNow交互的模型上下文协议服务器,通过安全API实现AI代理对ServiceNow数据的访问和操作,支持自然语言交互。

  • by lpacaniaNOW
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 lpacaniaNOW/servicenow-mcp

使用说明

ServiceNow MCP服务器

模型上下文协议(MCP)服务器,与ServiceNow接口,允许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

临床配置

要将此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": []
    }
  }
}

注: 确保使用具有以下内容的Python可执行文件的完整路径 mcp-server-servicenow 软件包已安装。

自然语言示例

搜索记录

您可以使用自然语言查询搜索记录:

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"

身份验证方法

服务器支持多种身份验证方法:

  1. 基本身份验证:用户名和密码
  2. 令牌身份验证:OAuth令牌
  3. 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

贡献

欢迎投稿!请随时提交拉取请求。

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。