Ops MCP Server Skill
Access your infrastructure's observability data and execute operational procedures through a unified MCP interface.
Capabilities at a Glance
| Module | Tools | What it answers |
|---|
| Events (Kubernetes) | INLINECODE0 , INLINECODE1 | What happened to a pod/deployment/node? |
| Metrics (Prometheus) |
list-metrics-from-prometheus,
query-metrics-from-prometheus,
query-metrics-range-from-prometheus | Is CPU/memory/traffic normal? What changed over time? |
|
Logs (Elasticsearch) |
list-log-indices-from-elasticsearch,
search-logs-from-elasticsearch,
query-logs-from-elasticsearch | What errors are in the logs? What did service X log? |
|
Traces (Jaeger) |
get-services-from-jaeger,
get-operations-from-jaeger,
find-traces-from-jaeger,
get-trace-from-jaeger | Why is this request slow? Where did it fail? |
|
SOPS |
list-sops-from-ops,
list-sops-parameters-from-ops,
execute-sops-from-ops | Run a standard operational procedure |
Setup (first-time)
CODEBLOCK0
How to Investigate: Decision Guide
When a user describes a problem, use this guide to choose starting tools and build a complete picture.
🔴 "Something is broken / service is down"
- 1. Kubernetes Events first — check if pods crashed, restarted, or got evicted
get-events-from-ops subject_pattern="ops.clusters.*.namespaces.<ns>.pods.*.events"
- 2. Logs — search for errors around the time of the incident
query-logs-from-elasticsearch query="FROM logs-* | WHERE @timestamp > NOW() - 30 minutes | WHERE level == 'error' | LIMIT 50"
- 3. Traces — find failed or slow requests
CODEBLOCK3
🟡 "Performance is degraded / requests are slow"
- 1. Metrics — check resource saturation
query-metrics-from-prometheus query="100 - (avg(rate(node_cpu_seconds_total{mode='idle'}[5m])) * 100)"
query-metrics-range-from-prometheus query="node_memory_MemAvailable_bytes" time_range="1h" step="1m"
- 2. Traces — find slow spans
find-traces-from-jaeger serviceName=<service> durationMin=1000
- 3. Logs — look for timeouts or slow query warnings
🔵 "I need to run a procedure / restart something"
- 1. List available SOPs
list-sops-from-ops
- 2. Get parameters
list-sops-parameters-from-ops sops_id=<id>
- 3. Execute
CODEBLOCK8
🟢 "General health check / nothing specific"
Start with events + a key metrics query, then go deeper based on what you find.
Tool Quick Reference
Events — NATS subject pattern format
CODEBLOCK9
Wildcards: * = one segment, > = everything remaining (tail only)
Observation types: status | events | alerts | INLINECODE20
Time is Unix milliseconds: INLINECODE21
Logs — ES|QL query patterns
CODEBLOCK10
Metrics — PromQL patterns
CODEBLOCK11
Detailed Examples & Reference Files
For complete parameter lists, output formats, and advanced patterns, read the relevant file:
- - events → INLINECODE22
- metrics → INLINECODE23
- logs → INLINECODE24
- traces → INLINECODE25
- sops → INLINECODE26
- event subject format design → INLINECODE27
Read the relevant example file before making complex tool calls you're unsure about.
What This Skill is NOT For
- - Direct infrastructure changes (use dedicated automation tooling)
- Real-time alerting (investigation only, not a monitoring agent)
- Writing to or modifying operational data (all access is read-only)
Ops MCP Server 技能
通过统一的 MCP 接口访问基础设施的可观测性数据并执行运维操作流程。
能力概览
| 模块 | 工具 | 解决的问题 |
|---|
| 事件 (Kubernetes) | list-events-from-ops, get-events-from-ops | Pod/部署/节点发生了什么? |
| 指标 (Prometheus) |
list-metrics-from-prometheus, query-metrics-from-prometheus, query-metrics-range-from-prometheus | CPU/内存/流量是否正常?随时间如何变化? |
|
日志 (Elasticsearch) | list-log-indices-from-elasticsearch, search-logs-from-elasticsearch, query-logs-from-elasticsearch | 日志中有哪些错误?服务 X 记录了哪些内容? |
|
链路追踪 (Jaeger) | get-services-from-jaeger, get-operations-from-jaeger, find-traces-from-jaeger, get-trace-from-jaeger | 请求为何缓慢?失败发生在哪里? |
|
SOP | list-sops-from-ops, list-sops-parameters-from-ops, execute-sops-from-ops | 执行标准运维流程 |
设置(首次使用)
bash
1. 使用 npx 运行 mcporter(无需安装)
或全局安装:npm i -g mcporter
2. 注册服务器
cd ~/.openclaw/workspace
npx mcporter config add ops-mcp-server --url http://localhost/mcp
3. 身份验证(如需)
npx mcporter auth ops-mcp-server
若失败,在 ~/.openclaw/workspace/config/mcporter.json 中添加:
headers: { Authorization: Bearer YOUR_TOKEN }
4. 验证
npx mcporter list ops-mcp-server
npx mcporter call ops-mcp-server list-events-from-ops page_size=5
5. 设置环境变量
export OPS
MCPSERVER_URL=http://localhost/mcp
如何排查:决策指南
当用户描述问题时,使用本指南选择起始工具并构建完整视图。
🔴 某功能故障/服务宕机
- 1. 首先检查 Kubernetes 事件 — 确认 Pod 是否崩溃、重启或被驱逐
get-events-from-ops subject_pattern=ops.clusters..namespaces..pods..events
- 2. 日志 — 搜索事件发生时间附近的错误
query-logs-from-elasticsearch query=FROM logs-* | WHERE @timestamp > NOW() - 30 minutes | WHERE level == error | LIMIT 50
- 3. 链路追踪 — 查找失败或缓慢的请求
find-traces-from-jaeger serviceName= tags={error:true}
🟡 性能下降/请求缓慢
- 1. 指标 — 检查资源饱和度
query-metrics-from-prometheus query=100 - (avg(rate(nodecpuseconds_total{mode=idle}[5m])) * 100)
query-metrics-range-from-prometheus query=nodememoryMemAvailablebytes timerange=1h step=1m
- 2. 链路追踪 — 查找慢 Span
find-traces-from-jaeger serviceName= durationMin=1000
- 3. 日志 — 查找超时或慢查询警告
🔵 需要执行流程/重启某组件
- 1. 列出可用 SOP
list-sops-from-ops
- 2. 获取参数
list-sops-parameters-from-ops sops_id=
- 3. 执行
execute-sops-from-ops sops_id= parameters={...}
🟢 常规健康检查/无特定问题
从事件和关键指标查询开始,根据发现结果深入排查。
工具快速参考
事件 — NATS 主题模式格式
命名空间资源
ops.clusters.{cluster}.namespaces.{ns}.{resourceType}.{name}.{observation}
节点级别
ops.clusters.{cluster}.nodes.{nodeName}.{observation}
通知
ops.notifications.providers.{provider}.channels.{channel}.severities.{severity}
通配符:* = 一个段,> = 剩余所有内容(仅限尾部)
观察类型:status | events | alerts | findings
时间使用 Unix 毫秒:$(date +%s)000
日志 — ES|QL 查询模式
sql
-- 近期错误
FROM logs-* | WHERE @timestamp > NOW() - 30 minutes | WHERE level == error | LIMIT 100
-- 按频率排序的常见错误
FROM logs-* | WHERE @timestamp > NOW() - 1 hour | WHERE level == error
| STATS count() BY message | SORT count DESC | LIMIT 10
-- 特定服务
FROM logs-* | WHERE service == checkout-service | WHERE @timestamp > NOW() - 1 hour | LIMIT 50
指标 — PromQL 模式
CPU 使用率
100 - (avg(rate(node
cpuseconds_total{mode=idle}[5m])) by (instance) * 100)
可用内存
node
memoryMemAvailable_bytes
HTTP 错误率
rate(http
requeststotal{status=~5..}[5m])
详细示例与参考文件
如需完整参数列表、输出格式和高级模式,请阅读相关文件:
- - 事件 → examples/events.md
- 指标 → examples/metrics.md
- 日志 → examples/logs.md
- 链路追踪 → examples/traces.md
- SOP → examples/sops.md
- 事件主题格式设计 → references/design.md
在调用不确定的复杂工具前,请先阅读相关示例文件。
本技能不适用于
- - 直接修改基础设施(请使用专用自动化工具)
- 实时告警(仅用于排查,非监控代理)
- 写入或修改运维数据(所有访问均为只读)