airthings
Retrieve current air quality data and device information from Airthings monitors to assess indoor environmental conditions.
Instructions
Get information about my Airthings air quality monitoring devices and their current sensor readings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:30-63 (handler)The 'airthings' tool handler is registered using server.tool and defined in src/server.ts. It fetches devices and sensor readings from the Airthings API and formats them as a text response.
server.tool( 'airthings', 'Get information about my Airthings air quality monitoring devices and their current sensor readings.', async () => { const devices = await client.getDevices(); const sensors = await client.getSensors(SensorUnits.Imperial); const lines: string[] = []; devices.devices.forEach((d) => { lines.push(`${d.name} is an Airthings ${d.type.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, char => char.toUpperCase())}` + ` with serial number ${d.serialNumber} that supports the following air quality sensors: ${d.sensors.join(', ')}.`); const sensorData = sensors.results.find(r => r.serialNumber === d.serialNumber); if (sensorData && sensorData.recorded) { lines.push(`Current air quality sensor readings for ${d.name}:`); sensorData.sensors.forEach((s) => { lines.push(`- ${s.sensorType}: ${s.value}${s.unit}`); }); } else { lines.push(`No current readings are available for ${d.name}.`); } lines.push(''); }); return { content: [{ type: 'text', text: lines.join('\n') }] }; } );