使用说明
ServiceNow MCP服务器
A. 模型上下文协议 用于ServiceNow事件管理的(MCP)服务器。它让AI助手喜欢 克莱恩 通过标准化的工具界面创建、读取、更新和解决事件。
特性
- 发生事故 --按编号检索事件详细信息
- 搜索_事故 --使用筛选器进行搜索(状态、优先级、分配组、分配的用户)
- 创建事件 --创建新事件
- update_事件 --更新现有事件的字段
- 添加注释 --添加工作笔记或客户可见的评论
- resolve_事件 --使用解决说明和代码解决事件
安全与安保
- PII编辑 默认情况下启用--电子邮件、电话号码、IP和SSN在到达LLM之前会被屏蔽
- 只读模式 通过
SERVICENOW_ALLOW_WRITE=false--禁用所有写入操作 - 输入验证 在所有票号和必填字段上
先决条件
- Node.js ≥ 18
- A. ServiceNow 具有REST API访问权限的实例(a 免费开发者实例 作品)
- ServiceNow API的Basic-auth凭据
快速开始
从npm安装
npx @dwiesendanger/servicenow-mcp
或者从源代码克隆和构建
git clone https://github.com/dwiesendanger/servicenow-mcp.git
cd servicenow-mcp
npm install
npm run build
配置
环境变量
复制 .env.example 到 .env 并填写您的值:
cp .env.example .env
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
SERVICENOW_INSTANCE_URL |
✅ | — | 您的实例URL,例如。 https://dev12345.service-now.com |
SERVICENOW_USERNAME |
✅ | — | ServiceNow用户名 |
SERVICENOW_PASSWORD |
✅ | — | ServiceNow密码 |
SERVICENOW_ALLOW_WRITE |
— | true |
设置为 false 禁用写入操作 |
SERVICENOW_DISABLE_REDACTION |
— | false |
设置为 true 禁用PII编辑 |
⚠️ 切勿将凭据放入MCP配置文件中。 始终使用
.env或操作系统级环境变量。看 安全.md 了解详情。
Cline/VS代码设置
创建一个 .env 项目目录中的文件(请参见 配置→ 环境变量 上面),然后将服务器添加到MCP设置文件中(cline_mcp_settings.json).
使用npx(推荐):
{
"mcpServers": {
"servicenow": {
"command": "npx",
"args": ["-y", "@dwiesendanger/servicenow-mcp"]
}
}
}
或者,如果你从源代码构建:
{
"mcpServers": {
"servicenow": {
"command": "node",
"args": ["/absolute/path/to/servicenow-mcp/dist/index.js"]
}
}
}
注: 服务器使用 Dotenv。 装载
.env从其工作目录。如果你的.env文件位于其他位置,您可以将变量设置为操作系统级环境变量或传递cwdMCP配置中的选项。
Claude桌面设置
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"servicenow": {
"command": "npx",
"args": ["-y", "@dwiesendanger/servicenow-mcp"]
}
}
}
发展
npm run dev # Run with tsx (hot-reload)
npm test # Run tests (vitest)
npm run test:watch # Watch mode
npm run build # Compile TypeScript → dist/
项目结构
src/
├── index.ts # Entry point, tool registration, MCP server setup
├── servicenow-client.ts # Axios-based ServiceNow REST API client
├── redaction.ts # PII redaction utilities
├── validation.ts # Input validation helpers
├── types.ts # Shared TypeScript types
├── tools/
│ ├── get-incident.ts # get_incident handler
│ ├── search-incidents.ts # search_incidents handler
│ ├── create-incident.ts # create_incident handler
│ ├── update-incident.ts # update_incident handler
│ ├── add-comment.ts # add_comment handler
│ └── resolve-incident.ts # resolve_incident handler
└── __tests__/
├── validation.test.ts # Validation unit tests
└── redaction.test.ts # Redaction unit tests
贡献
- 分叉存储库
- 创建要素分支(
git checkout -b feature/my-feature) - 通过测试进行更改
- 跑
npm test确保测试通过 - 承诺并推动
- 打开拉取请求
