ServiceNow MCP 集成服务器

ServiceNow MCP集成服务器通过标准化协议实现ServiceNow实例与AI模型的无缝交互,支持自动化事件管理、知识库文章创建等多种ServiceNow操作。

  • by divyashah0510
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 divyashah0510/mcp-server-servicenow

使用说明

🚀 ServiceNow MCP服务器

ServiceNow Integration for Model Context Protocol

📋 概述

此存储库包含用于模型上下文协议(MCP)的ServiceNow集成服务器。它通过标准化的协议实现了ServiceNow实例和AI模型之间的无缝交互,允许自动事件管理、知识库文章创建和其他ServiceNow操作。

✨ 特性

  • 🔌 ServiceNow集成:与ServiceNow实例直接集成
  • 🛠️ 多种操作支持:
    • 创建和管理事件
    • 创建知识库文章
    • 创建客户端脚本
    • 创建业务规则
    • 创建SLA定义
    • 创建唱片制作人
  • 🔒 安全认证:基于环境的凭据管理
  • 🚀 基于FastAPI的服务器:高性能异步操作

🛠️ 先决条件

  • Python 3.12或更高版本
  • 具有适当API访问权限的ServiceNow实例
  • 有效的ServiceNow凭据
  • 可选:Gemini API AI功能密钥
  • 用于运行服务器的UV图标
  • 用于构建服务器的FastAPI

⚙️ 配置

  1. 克隆存储库:

    git clone https://github.com/your-org/mcp-server-now.git
    cd mcp-server-now
    
  2. 创建一个 .env 使用您的凭据文件:

    SERVICENOW_INSTANCE=https://your-instance.service-now.com
    SERVICENOW_USERNAME=your_username
    SERVICENOW_PASSWORD=your_password
    GEMINI_API_KEY=your_api_key  # Optional
    
  3. 安装依赖项:

    pip install -e .
    

🚀 入门指南

运行服务器

mcp install <file_name>.py

示例用法

服务器为ServiceNow操作提供了多种工具。以下是一些示例:

  1. 创建偶发事件:

    create_incident(
        short_description="Network outage in building B",
        description="Users reporting connectivity issues",
        urgency="2",
        impact="2"
    )
    
  2. 创建知识库文章:

    create_kb_article(
        short_description="How to Reset Your Password",
        article_body="<h1>Password Reset Instructions</h1><p>1. Navigate to the login page</p>",
        workflow_state="published"
    )
    

有关更多示例,请参见 servicenow-test-examples.md.

🧩 可用工具

服务器提供以下工具:

  • create_incident:创建新事件
  • create_kb_article:创建知识库文章
  • create_client_script:创建客户端脚本
  • create_business_rule:创建业务规则
  • create_sla_definition:创建SLA定义
  • create_record_producer:使用可定制的变量创建唱片制作人
  • create_variable_set:为目录项创建可重用的变量集

唱片制作人详细信息

这 create_record_producer 该工具允许您创建具有以下功能的ServiceNow记录生成器:

create_record_producer(
    name="Report Network Issue",
    table_name="incident",
    short_description="Use this form to report network connectivity issues",
    category_sys_id="optional_category_sys_id",
    script="optional_server_side_script",
    variables=[
        {
            "name": "issue_type",
            "label": "Type of Issue",
            "type": "choice",
            "choices": ["Connectivity", "Performance", "Access"],
            "mandatory": True
        },
        {
            "name": "affected_users",
            "label": "Number of Affected Users",
            "type": "integer",
            "mandatory": True
        }
    ]
)

主要特点:

  • 各种类型(字符串、整数、布尔值、引用等)的可定制表单字段
  • 服务器端脚本支持
  • 类别分配
  • 必填字段配置
  • 默认值和帮助文本

变量集

这 create_variable_set 该工具允许您创建可重用的变量集,这些变量集可以附加到多个目录项:

create_variable_set(
    name="Hardware Request Variables",
    description="Common variables for hardware requests",
    variables=[
        {
            "name": "device_type",
            "label": "Device Type",
            "type": "choice",
            "choices": ["Laptop", "Desktop", "Tablet", "Phone"],
            "mandatory": True
        },
        {
            "name": "justification",
            "label": "Justification",
            "type": "text",
            "mandatory": True,
            "help_text": "Please explain why you need this hardware"
        }
    ]
)

变量集支持:

  • 多种变量类型(字符串、整数、布尔值、引用、选择等)
  • 自定义验证规则
  • 帮助文本和说明
  • 必填字段配置
  • 默认值
  • 其他ServiceNow表的引用字段

🔧 发展

项目结构

mcp-server-now/
├── servicenow.py          # Main server implementation
├── servicenow-test-examples.md  # Example usage
├── pyproject.toml         # Project configuration
├── .env                   # Environment variables
└── README.md             # This file

添加新工具

要添加新的ServiceNow操作,请执行以下操作:

  1. 在中创建一个新的异步函数 servicenow.py
  2. 用 @mcp.tool()
  3. 添加适当的文档和错误处理
  4. 测试新功能

📚 资源

📄 许可证

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

📞 支持

如需支持,请:

👤 作者

Divya Shah

AI Engineer | ServiceNow Developer | Open Source Contributor

GitHub • LinkedIn • Twitter


🎥 观看现场演示

🔗 Youtube链接

现场演示

Made with ❤️ by Divya Shah