Skip to main content
Glama

get-current-observations-by-reporting-area-by-lat-long

Retrieve current Air Quality Index (AQI) values and categories for a specific location using latitude and longitude. Supports multiple output formats and includes nearby reporting area data if necessary.

Instructions

Get current AQI values and categories for a reporting area by latitude and longitude.

Input Schema

NameRequiredDescriptionDefault
distanceNoIf no reporting area is associated with the latitude and longitude, current observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150
formatYesFormat of the payload file returned. Example: application/json
latitudeYesLatitude in decimal degrees. Example: 38.33
longitudeYesLongitude in decimal degrees. Example: -122.28

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "distance": { "description": "If no reporting area is associated with the latitude and longitude, current observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150", "type": "string" }, "format": { "description": "Format of the payload file returned. Example: application/json", "enum": [ "text/csv", "application/json", "application/xml" ], "type": "string" }, "latitude": { "description": "Latitude in decimal degrees. Example: 38.33", "type": "string" }, "longitude": { "description": "Longitude in decimal degrees. Example: -122.28", "type": "string" } }, "required": [ "latitude", "longitude", "format" ], "type": "object" }

Implementation Reference

  • The MCP tool handler function that fetches data using the AirNow API helper and returns it as text content or an error message.
    async (params) => { const result = await airnowApi.fetchCurrentObservationsByReportingAreaByLatLong( params ); if (result === null) { return { content: [ { type: "text", text: "Failed to fetch current observations data from AirNow API.", }, ], isError: true, }; } return { content: [ { type: "text", text: result, }, ], }; }
  • Zod schema for tool input parameters: latitude, longitude, format, and optional distance.
    { latitude: z .string() .describe("Latitude in decimal degrees. Example: 38.33"), longitude: z .string() .describe("Longitude in decimal degrees. Example: -122.28"), format: z .enum(["text/csv", "application/json", "application/xml"]) .describe( "Format of the payload file returned. Example: application/json" ), distance: z .string() .optional() .describe( "If no reporting area is associated with the latitude and longitude, current observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150" ), },
  • The server.tool call that registers the tool, including name, description, input schema, and handler function.
    server.tool( "get-current-observations-by-reporting-area-by-lat-long", "Get current AQI values and categories for a reporting area by latitude and longitude.", { latitude: z .string() .describe("Latitude in decimal degrees. Example: 38.33"), longitude: z .string() .describe("Longitude in decimal degrees. Example: -122.28"), format: z .enum(["text/csv", "application/json", "application/xml"]) .describe( "Format of the payload file returned. Example: application/json" ), distance: z .string() .optional() .describe( "If no reporting area is associated with the latitude and longitude, current observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150" ), }, async (params) => { const result = await airnowApi.fetchCurrentObservationsByReportingAreaByLatLong( params ); if (result === null) { return { content: [ { type: "text", text: "Failed to fetch current observations data from AirNow API.", }, ], isError: true, }; } return { content: [ { type: "text", text: result, }, ], }; } );
  • Helper function that constructs the API request to AirNow's current observations endpoint by lat/long and calls the generic airnowGet fetcher.
    export async function fetchCurrentObservationsByReportingAreaByLatLong(params: Record<string, string>): Promise<string | null> { const endpoint = 'aq/observation/latlong/current/'; const queryParams = new URLSearchParams(); queryParams.append('latitude', params.latitude); queryParams.append('longitude', params.longitude); queryParams.append('format', params.format); if (params.distance) queryParams.append('distance', params.distance); return airnowGet(endpoint, queryParams); }
  • Invocation of the tool registration function within the central registerTools function.
    registerCurrentObservationsByLatLong(server);

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/prsantos-com/airnow-mcp-server'

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