Skip to main content
Glama
AnuwatThisuka

CMMS MCP Server

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
NameRequiredDescriptionDefault
sensorIdNoFilter by sensor ID
statusNoFilter by reading status
hoursNoGet readings from last N hours

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AnuwatThisuka/cmms-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server