Skip to main content
Glama
Helios Field Service

Helios Field Service

Helios Field Service — 生产级 MCP 服务器与客户端

模块 4 实验 — Model Context Protocol

将 Helios Robotics 的零部件、库存和 RMA 系统转化为一种 MCP 能力,任何支持 MCP 的客户端都可以接入。基于 FastMCP 3.x 构建,遵循 MCP 规范。

需求

实现

≥3 个工具

4 — search_parts, get_inventory, analyse_failure, create_rma

≥2 个资源

3 — helios://catalog/summary + 两个 URI 模板

≥1 个提示词

diagnose_fault(fault_code, sku, site)

客户端发现并调用每一项

client.py — 列出全部三项,并调用全部三项

传输方式 + 理由

stdio(默认),支持 HTTP — 理由

客户端侧安全

两者兼备 — 写入时的征求确认(elicitation),客户端上的根目录(roots)

安全设计摘要

docs/security.md

错误处理

无效输入、未知记录,以及后备存储不可达

文档:架构 + 传输 · 工具/资源/提示词 · 安全 · 日志:logs/

快速开始

python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python seed_data.py
python client.py            # spawns the server over stdio and runs the full demo

无需 API 密钥,无需模型,零成本 — MCP 是一种协议,客户端直接调用服务器。

其他运行方式

AUTO_APPROVE=1 python client.py           # non-interactive (CI, log capture)
SIMULATE_DB_OUTAGE=1 python client.py     # backing data source unreachable
MCP_TRANSPORT=http python server.py       # serve on 127.0.0.1:8000
MCP_TRANSPORT=http python client.py       # ...and connect to it

在任何 MCP 宿主中使用

{
  "mcpServers": {
    "helios-field-service": {
      "command": "python",
      "args": ["/absolute/path/to/helios-mcp/server.py"]
    }
  }
}

这正是本练习的意义所在 — 构建一次,任何支持 MCP 的客户端都能使用。

Related MCP server: Latchbook

演示内容

logs/demo.log — 完整的发现与调用流程:

1. DISCOVERY — tools
  • search_parts       [read-only]  Search the Helios spare parts catalogue...
  • get_inventory      [read-only]  Stock level and lead time for a part...
  • analyse_failure    [read-only]  Correlate a fault code with known issues...
  • create_rma         [WRITE]      Raise a Return Material Authorisation.

1. DISCOVERY — resources
  • helios://catalog/summary         Catalogue summary
  • helios://parts/{part_number}     Catalogue entry  (template)
  • helios://kb/{doc_id}             Knowledge base article  (template)

1. DISCOVERY — prompts
  • diagnose_fault(fault_code, sku, site)

写入操作,由征求确认(elicitation)把关:

  ┌─ SERVER REQUESTS CONFIRMATION ──────────────────────────────────
  │ Raise an RMA for 1 x HX2-BMS-03 (HX-200 Battery Management Board rev C)?
  │ Serial: HX200-PHX-0442
  │ Total value: $1,240.00
  └─────────────────────────────────────────────────────────────────
{"created": true, "rma_id": "RMA-00001", "value_usd": 1240.0,
 "requested_by": "mahesh.s"}

logs/demo-db-outage.log — 后备存储不可达。客户端看到的内容:

TOOL UNAVAILABLE — Failure analysis is temporarily unavailable.
                   Quote reference dddc45d0fc07 to support if this persists.

服务器记录到 stderr 的内容(logs/server-errors.log):

ERROR [helios-mcp] [dddc45d0fc07] Failure analysis failed:
OperationalError: could not connect to helios-db-prod-01.internal:5432: timeout

主机名和端口永远不会越过协议边界。correlation id(关联 ID)是两者之间的桥梁。

设计说明

资源和工具不可互换。 search_parts 在不知道零件 ID 时查找零件;helios://parts/{pn} 获取你已经知道 ID 的零件。数据相同,访问模式不同。

提示词特意放在服务器端。 诊断流程是 Helios 的领域知识,而不是宿主逻辑。每个接入的客户端都会得到相同的规则 — 先排除固件问题,再判定硬件故障;绝不报价已淘汰的零件 — 而不是各自重新实现并逐渐偏离。

所有日志都输出到 stderr。 在 stdio 上,stdout 承载 JSON-RPC 帧。任何多余的 print() 都会破坏协议流;服务器中不存在这种情况。

客户端控制服务器的环境。 派生的 stdio 服务器不会自动继承父环境,因此 PythonStdioTransport(env=...) 传递的是显式的允许列表,而不是将调用方的整个 shell 都交出去。

目录结构

server.py            MCP server: 4 tools, 3 resources, 1 prompt
client.py            MCP client: discovery, invocation, elicitation, roots
seed_data.py         Creates data/helios.db
docs/
  architecture.md    Diagrams + transport justification
  capabilities.md    Every tool, resource and prompt documented
  security.md        Auth, least privilege, error redaction
logs/
  demo.log                 Successful discovery-and-invocation flow
  demo-db-outage.log       Backing store unreachable, client view
  server-errors.log        Server-side detail with correlation ids

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search and retrieve source-linked robotics projects, bills of materials, and technical components, compare components, and validate RPPS documents via a remote MCP endpoint.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an MCP client to resolve household appliances, retrieve local manual/warranty/incident records, compare a stored warranty date, review persistent service case history, and draft cited repair cases that only a human can approve or close before export.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to browse a read-only catalog of published products and their documented interfaces, listing entries, fetching one by stable ID, and searching names, descriptions, and limitations with optional protocol filters. It also exposes the versioned manifest as a resource and a prompt that helps clients match a task to catalog entries without inventing unsupported capabilities.
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables MCP clients to search and manage customer support tickets, customer records, and knowledge base articles, with read-only and human-approved write workflows.
      8
      1
      MIT