get_sensor_readings
Retrieve IoT sensor data for manufacturing operations, with filtering options by sensor, status, or time range to monitor equipment conditions.
Instructions
Get sensor readings from IoT system. Can filter by sensor, status, or time range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sensorId | No | Filter by sensor ID | |
| status | No | Filter by reading status | |
| hours | No | Get readings from last N hours |
Implementation Reference
- src/index.ts:781-813 (handler)The handler function `handleGetSensorReadings` filters and returns sensor readings based on `sensorId`, `status`, and `hours`.
private handleGetSensorReadings(args: { sensorId?: string; status?: string; hours?: number; }) { let readings = [...mockSensorReadings]; if (args.sensorId) { readings = readings.filter((r) => r.sensorId === args.sensorId); } if (args.status) { readings = readings.filter((r) => r.status === args.status); } if (args.hours) { const cutoff = new Date(Date.now() - args.hours * 3600000); readings = readings.filter((r) => new Date(r.timestamp) >= cutoff); } // Sort by timestamp descending readings.sort( (a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime() ); return { content: [ { type: "text", text: JSON.stringify(readings, null, 2), }, ], }; } - src/index.ts:288-310 (schema)Schema definition for `get_sensor_readings` tool.
{ name: "get_sensor_readings", description: "Get sensor readings from IoT system. Can filter by sensor, status, or time range.", inputSchema: { type: "object", properties: { sensorId: { type: "string", description: "Filter by sensor ID", }, status: { type: "string", enum: ["normal", "warning", "critical"], description: "Filter by reading status", }, hours: { type: "number", description: "Get readings from last N hours", }, }, }, }, - src/index.ts:400-401 (registration)Registration of the `get_sensor_readings` tool in the request handler switch statement.
case "get_sensor_readings": return this.handleGetSensorReadings(args as any);