Skip to main content
Glama
prsantos-com

AirNow MCP Server

by prsantos-com

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

Retrieve historical air quality index (AQI) values and categories for a specific location using latitude and longitude, with data available in CSV, JSON, or XML formats. Ideal for analyzing past air quality trends in a reporting area or nearby regions.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesDate to get the historical observations for. Format: YYYY-MM-DD. Example: 2012-02-01
distanceNoIf no reporting area is associated with the latitude and longitude, historical 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

Implementation Reference

  • The MCP tool handler function that calls the AirNow API helper to fetch historical observations and returns the result as text content or an error message.
    async (params) => {
      const result =
        await airnowApi.fetchHistoricalObservationsByReportingAreaByLatLong(
          params
        );
      if (result === null) {
        return {
          content: [
            {
              type: "text",
              text: "Failed to fetch historical observations data from AirNow API.",
            },
          ],
          isError: true,
        };
      }
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the tool: latitude, longitude, date, 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"),
      date: z
        .string()
        .describe(
          "Date to get the historical observations for. Format: YYYY-MM-DD. Example: 2012-02-01"
        ),
      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, historical observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150"
        ),
    },
  • Registration of the tool on the MCP server within the registerHistoricalObservationsByLatLong function, specifying name, description, input schema, and handler.
    server.tool(
      "get-historical-observations-by-reporting-area-by-lat-long",
      "Get historical 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"),
        date: z
          .string()
          .describe(
            "Date to get the historical observations for. Format: YYYY-MM-DD. Example: 2012-02-01"
          ),
        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, historical observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150"
          ),
      },
      async (params) => {
        const result =
          await airnowApi.fetchHistoricalObservationsByReportingAreaByLatLong(
            params
          );
        if (result === null) {
          return {
            content: [
              {
                type: "text",
                text: "Failed to fetch historical observations data from AirNow API.",
              },
            ],
            isError: true,
          };
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Call to register this specific tool within the overall tools registration in src/tools/index.ts.
    registerHistoricalObservationsByLatLong(server);
  • Helper function that constructs the AirNow API request for historical observations by lat/long and fetches the data using the shared airnowGet function.
    export async function fetchHistoricalObservationsByReportingAreaByLatLong(params: Record<string, string>): Promise<string | null> {
      const endpoint = 'aq/observation/latlong/historical/';
      const queryParams = new URLSearchParams();
      queryParams.append('latitude', params.latitude);
      queryParams.append('longitude', params.longitude);
      queryParams.append('date', params.date);
      queryParams.append('format', params.format);
      if (params.distance) queryParams.append('distance', params.distance);
    
      return airnowGet(endpoint, queryParams);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions retrieving 'historical AQI values and categories' but fails to describe key behaviors: whether this is a read-only operation, potential rate limits, error handling (e.g., if no reporting area is found), or the structure of the returned data. The description is minimal and lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It does not address behavioral aspects like data format details, error scenarios, or how the 'distance' parameter affects results, leaving significant gaps for an agent to understand proper usage and expectations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description does not add any parameter-specific information beyond what is already detailed in the input schema, which has 100% coverage with clear descriptions for all parameters. Since the schema fully documents the parameters, the baseline score of 3 is appropriate, as the description provides no additional semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get historical AQI values and categories') and the target ('for a reporting area by latitude and longitude'), making the purpose understandable. However, it does not explicitly differentiate this tool from its sibling 'get-historical-observations-by-reporting-area-by-zip-code', which serves a similar purpose but uses a different input method (zip code vs. lat/long).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as the sibling tools for current observations, forecasts, or historical data by zip code. It lacks explicit context about use cases, prerequisites, or exclusions, leaving the agent to infer usage based on parameter names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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