motor-telemetry-mcp
Exposes industrial motor telemetry data to AI agents via MCP and REST, enabling natural-language queries about motor status, health, and alerts. Provides a single tool and resource for retrieving real-time motor metrics and escalating critical conditions.
README
Industrial Motor Telemetry — MCP Server (PoC)
A Proof of Concept that exposes an industrial motor telemetry system to an AI agent through the Model Context Protocol (MCP), while also serving a conventional FastAPI REST interface — both backed by the same async service layer.
Why this design
| Concern | Where it lives | Rationale |
|---|---|---|
| Data contract | models.py (MotorStatus, MotorHealth) |
Single source of truth, validated by Pydantic v2. |
| Business logic | telemetry_service.py (get_motor_status) |
Transport-agnostic async logic; no FastAPI/MCP imports → unit-testable and reusable. |
| Transports | main.py |
MCP tool and REST endpoint both delegate to the one service coroutine — zero logic duplication. |
The MCP server (built on the official mcp SDK's MCPServer) is served over
Streamable HTTP and mounted onto the FastAPI app, so a single uvicorn
process exposes both protocols.
Requirements
- Python 3.10+
- Dependencies in
requirements.txt(FastAPI, Uvicorn, Pydantic v2,mcpv2)
Run locally
cd motor-telemetry-mcp
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Start the combined REST + MCP server
uvicorn main:app --reload --port 8000
- MCP endpoint (Streamable HTTP):
http://localhost:8000/mcp - REST docs (Swagger UI):
http://localhost:8000/docs
Try the REST API
curl http://localhost:8000/motors # list motor IDs
curl http://localhost:8000/motors/MTR-001 # NORMAL
curl http://localhost:8000/motors/MTR-003 # CRITICAL (overheating)
curl -i http://localhost:8000/motors/MTR-999 # 404 with clear detail
Run the tests
pip install -r requirements-dev.txt
pytest
The suite (14 tests) covers all three layers with no network sockets:
tests/test_service.py— async domain logic (health mapping, forgiving input normalization, not-found error).tests/test_rest_api.py— FastAPI endpoints via httpx's in-process ASGI transport (200s, structured body, 404).tests/test_mcp_tool.py— MCP layer in-process: tool discovery, input schema, structured output, and the tool-error path.
Run with Docker
docker build -t motor-telemetry-mcp .
docker run --rm -p 8000:8000 motor-telemetry-mcp
The image is slim, installs deps in a cached layer, runs as a non-root
user, and ships a container HEALTHCHECK against /health.
Mock fleet
| Motor ID | Temp (°C) | Vibration (mm/s) | RPM | Status |
|---|---|---|---|---|
MTR-001 |
62.5 | 1.8 | 1490 | NORMAL |
MTR-002 |
83.0 | 4.2 | 1475 | WARNING |
MTR-003 |
118.4 | 11.6 | 1360 | CRITICAL |
How an AI agent connects to the MCP tool
The server advertises one tool, get_motor_status_tool, and one resource,
motor://fleet. An MCP-capable agent runtime discovers and invokes it exactly
like the included client_example.py:
# In a second terminal, with the server running:
python client_example.py
Conceptual flow:
- Connect — the agent's MCP client opens a Streamable-HTTP session to
http://localhost:8000/mcp. - Discover — it calls
list_tools()and receives the schema forget_motor_status_tool(auto-generated from the Python type hints). - Invoke — when the user asks "Is motor MTR-003 healthy?", the LLM emits
a tool call
get_motor_status_tool(motor_id="MTR-003"). - Reason — the server returns structured JSON (temperature, vibration,
rpm, status). The agent reads
status: "CRITICAL"and can respond / escalate. Unknown motors return an MCP tool error result, which the agent can surface gracefully.
Wiring it into a real client (e.g. Claude Desktop / any MCP host)
Point the host at the Streamable-HTTP URL. Example host config entry:
{
"mcpServers": {
"motor-telemetry": {
"type": "http",
"url": "http://localhost:8000/mcp"
}
}
}
Project layout
motor-telemetry-mcp/
├── models.py # Pydantic models: MotorStatus, MotorHealth enum
├── telemetry_service.py # Async, transport-agnostic domain logic + mock data
├── main.py # FastAPI app + MCP server (Streamable HTTP) mounted
├── client_example.py # Demo MCP client that calls the tool
├── tests/ # pytest suite (service, REST, MCP layers)
├── Dockerfile # Slim, non-root container image
├── .dockerignore
├── pytest.ini
├── requirements.txt
├── requirements-dev.txt # test/dev dependencies
└── README.md
Production notes (talking points)
- Swap
telemetry_serviceinternals for a real historian / OPC-UA / time-series source — no transport code changes needed. stateless_http=Truekeeps the MCP transport horizontally scalable.- Add auth (the
mcpSDK supports token verifiers / OAuth resource servers) and rate limiting before exposing beyond localhost.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。