machine-maintenance-agent
Machine Maintenance Agent: MCP 面试项目
这是一个小型、可直接用于面试的项目,演示了代理如何使用 MCP 工具检查工业机器数据、搜索维护指南,并在需要升级处理时创建维护工单。
示例场景:
"机器 P-204 振动异常。我该怎么办?"
代理会检查模拟的机器状态、查看最近的传感器异常、搜索维护手册数据集,并可选地创建工单。
为什么这是一个很好的 MCP 示例
MCP 在这里很有用,因为代理不需要直接访问数据库或文件。相反,它获得一个受控的工具接口:
get_machine_status_tool(machine_id)get_recent_sensor_anomalies_tool(machine_id, hours)search_maintenance_manual_tool(query, limit)create_maintenance_ticket_tool(machine_id, severity, summary, recommended_action)list_open_tickets_tool(machine_id)
这让你可以在一个小项目中解释只读数据访问、安全的写入访问、工具边界以及多步骤代理行为。
Related MCP server: Nibble
项目结构
machine-maintenance-agent/
data/
machines.json # Machine metadata and normal operating ranges
machine_status.json # Current synthetic sensor readings
anomalies.json # Recent detected anomalies
maintenance_manual.json # Small troubleshooting knowledge base
tickets.json # Simple local ticket store
src/
maintenance_tools.py # Core tool logic
mcp_server.py # MCP server exposing tools
agent_demo.py # Transparent agent flow demo
tests/
test_maintenance_tools.py
AGENT_FLOW.md
TOOL_CONTRACTS.md
requirements.txt
README.md设置
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtMCP 依赖项固定在当前稳定的 Python SDK v1 版本线上:mcp[cli]>=1.27,<2。
运行演示代理
从该文件夹运行:
python src/agent_demo.py要在演示期间创建工单:
python src/agent_demo.py --create-ticket预期行为:
读取
P-204的状态。发现振动和温度超出正常范围。
发现高严重性的振动异常。
在维护手册中搜索泵振动指南。
建议降低负载并检查轴承/联轴器区域。
仅在使用
--create-ticket时创建工单。
运行 MCP 服务器
python src/mcp_server.py这会启动一个 stdio MCP 服务器。MCP 客户端可以连接到它并调用暴露的工具。
示例 MCP 客户端配置形式:
{
"mcpServers": {
"machine-maintenance-agent": {
"command": "python",
"args": ["src/mcp_server.py"],
"cwd": "/absolute/path/to/machine-maintenance-agent"
}
}
}运行测试
python -m unittest discover -s tests面试讲解
使用这个简短的解释:
"我围绕一个模拟维护系统构建了一个 MCP 服务器。代理不能自由查询文件或数据库。它只能获得几个工具:读取机器状态、读取异常、搜索手册以及创建维护工单。对于泵 P-204 的振动投诉,代理检查实时状态,看到振动超过阈值,发现近期高严重性异常,检索相关手册指南,并通过创建工单进行升级。这展示了受控的企业访问、基于工具的推理,以及 LLM 与运营系统之间的安全边界。"
如需更结构化的讲解,请参阅 AGENT_FLOW.md 和 TOOL_CONTRACTS.md。
此项目使用的数据
机器元数据:ID、名称、区域、关键性、正常运行范围。
机器状态:当前振动、温度、压力、状态、上次维护日期。
传感器异常:时间戳、信号、数值、阈值、严重性、描述。
维护手册:症状、关键词、建议操作、安全注意事项。
工单存储:工单 ID、机器 ID、严重性、摘要、建议操作、状态。
如何扩展它
针对作品集版本的小型后续改进:
添加一个能够动态选择工具的真实 LLM 客户端。
使用 SQLite 替代 JSON 文件。
添加基于角色的权限,例如只读操作员访问权限和工单写入主管访问权限。
添加一个显示机器状态和未结工单的简单仪表板。
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Set up and run your firm's Precision AI agents, skills and routines from any MCP client.
Compliance frameworks (SOC 2, ISO 27001, CMMC, NIST, more) delivered to AI agents as MCP tools.
One MCP for any agent: your connected apps, shared memory, web search, social data and media tools.
Related MCP Servers
- AlicenseCqualityBmaintenanceEnables AI agents to manage system updates, application installations, and remote host orchestration through MCP tools.263MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to investigate production incidents by exposing service health, logs, and deployment data through MCP tools.5 npmISC
- AlicenseAqualityAmaintenanceEnables AI agents to monitor server health and capacity, diagnose outages, inspect Docker and deployment status, and perform safe, bounded recovery actions via MCP without granting unrestricted shell or SSH access.101Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables SafeOps operators to monitor worker health, inspect job queues, investigate incidents, search runbooks, and approve or reject targeted failed-job retries through MCP tools, resources, and a prompt.-