Skip to main content
Glama
matheuscalma

servicenow-mcp

by matheuscalma

servicenow-mcp

一个轻量级的 MCP 服务器,让 AI 代理能够通过 Table API 创建、搜索和更新 ServiceNow 事件。基于官方 Python mcp 包(FastMCP 风格装饰器)、httpxpython-dotenv 构建。通过 stdio 运行。

所有代码都集中在一个文件中:server.py

设置

需要 Python 3.12+ 和 uv

uv sync

server.py 旁边创建一个 .env 文件(已被 git 忽略),其中包含你实例的基本认证凭据——使用 个人开发者实例 即可:

SNOW_INSTANCE_URL=https://devXXXXXX.service-now.com
SNOW_USERNAME=admin
SNOW_PASSWORD=your-password
# optional, default 15
SNOW_TIMEOUT_SECONDS=15

运行服务器(它通过 stdin/stdout 使用 MCP 协议通信,因此没有可见输出——必须由 MCP 客户端启动):

uv run server.py

注册到 MCP 客户端

将客户端指向 uv 和项目目录,以便正确加载 .venv.env

{
  "mcpServers": {
    "servicenow": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/servicenow-mcp", "run", "server.py"]
    }
  }
}

对于 Claude Code:claude mcp add servicenow -- uv --directory /absolute/path/to/servicenow-mcp run server.py

客户端环境中已设置的环境变量优先级高于 .env

Related MCP server: sn-mcp-bridge

工具

工具

参数

功能

返回结果

create_incident

short_description: str(必填)· description: str = "" · urgency: str = "3""1" 高,"2" 中,"3" 低)

创建新事件。

{number, sys_id, short_description, state, urgency}

query_incidents

query_text: str = "" · state: str = "" · limit: int = 5(1–100)

按最新时间列出事件。query_text 如果类似 INC0010001 则精确匹配编号;其他文本执行 ServiceNow 关键字搜索(123TEXTQUERY321),失败时回退到对 short_description/description 的 LIKE 匹配,以便找到刚创建的记录。state 接受代码("1""8")或名称(NewIn ProgressOn HoldResolvedClosedCanceled)。

[{number, sys_id, short_description, state, state_code, urgency, created_on}, …]

update_incident

number: str(必填)· work_notes: str = "" · state: str = ""

按编号查找事件,追加工作备注和/或设置状态。work_notes/state 至少需要提供一个。

{number, sys_id, changed: {…}, state}

所有工具在出错时都会返回可读的工具错误(以 isError 形式呈现给代理),而不是堆栈跟踪,例如:

  • Authentication failed (401): check SNOW_USERNAME and SNOW_PASSWORD. ServiceNow said: User is not authenticated …

  • Could not connect to https://…: [Errno 8] nodename nor servname provided … Check SNOW_INSTANCE_URL and your network connection.

  • Timed out after 15s talking to https://… The instance may be hibernating (PDI) or unreachable.

  • Incident 'INC9999999' was not found on https://….

  • Forbidden (403): the user lacks permission … or the update was rejected by a business rule. ServiceNow said: … (例如,在未填写解决字段的情况下解决事件)。

设计说明

  • ServiceNowClient 封装了一个 httpx.AsyncClient(基本认证、JSON 头、超时),并暴露了 create_record / query_records / get_record_by_number / update_record 方法。所有错误都被转换为带有可读消息的 ServiceNowError

  • 工具通过 get_client() 获取客户端;在测试中调用 set_client(fake) 即可替换为模拟对象,无需访问网络。

  • 记录通过 sysparm_display_value=all 获取,因此状态/紧急程度标签来自实例本身,而非硬编码映射(友好名称别名仅用于输入)。

  • mcp 2.x 将 FastMCP 重命名为 MCPServerserver.py 会导入存在的版本,因此可在 1.x 和 2.x 上运行。

冒烟测试

针对真实实例运行(会写入一个事件):

uv run python -c "
import asyncio, server
async def main():
    c = await server.create_incident('MCP server smoke test', 'created by smoke test')
    print(c)
    print(await server.query_incidents(query_text='MCP server smoke test'))
    print(await server.update_incident(c['number'], work_notes='hello from MCP'))
asyncio.run(main())
"
Install Server
F
license - not found
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    An MCP server for interacting with a ServiceNow instance via its Table API, enabling CRUD operations on incident, request, and requested item tables, as well as generic operations on any table by name.
    22
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server for AI dialogue using various LLM models via AceDataCloud

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matheuscalma/servicenow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server