Skip to main content
Glama
prsantos-com

AirNow MCP Server

by prsantos-com

get-historical-observations-by-reporting-area-by-zip-code

Retrieve historical air quality index (AQI) values and categories for a specific reporting area using a Zip code and date. Supports output in CSV, JSON, or XML formats.

Instructions

Get historical AQI values and categories for a reporting area by Zip code.

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 Zip code, 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
zipCodeYesZip code to get the historical observations for. Example: 94954

Implementation Reference

  • MCP tool handler that invokes the AirNow API and returns the response as text content or an error.
    async (params) => {
      const result =
        await airnowApi.fetchHistoricalObservationsByReportingAreaByZipCode(
          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.
      zipCode: z
        .string()
        .describe(
          "Zip code to get the historical observations for. Example: 94954"
        ),
      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 Zip code, historical observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150"
        ),
    },
  • Function that registers the tool with the MCP server, including name, description, schema, and handler.
    export const registerHistoricalObservationsByZipCode = (server: McpServer): void => {
      server.tool(
        "get-historical-observations-by-reporting-area-by-zip-code",
        "Get historical AQI values and categories for a reporting area by Zip code.",
        {
          zipCode: z
            .string()
            .describe(
              "Zip code to get the historical observations for. Example: 94954"
            ),
          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 Zip code, 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.fetchHistoricalObservationsByReportingAreaByZipCode(
              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,
              },
            ],
          };
        }
      );
    };
  • Core helper function that performs the HTTP request to the AirNow API for historical observations by zip code.
    export async function fetchHistoricalObservationsByReportingAreaByZipCode(params: Record<string, string>): Promise<string | null> {
      const endpoint = 'aq/observation/zipcode/historical/';
      const queryParams = new URLSearchParams();
      queryParams.append('zipCode', params.zipCode);
      queryParams.append('date', params.date);
      queryParams.append('format', params.format);
      if (params.distance) queryParams.append('distance', params.distance);
    
      return airnowGet(endpoint, queryParams);
    }
  • Imports and calls the register function as part of registering all tools.
    import { registerHistoricalObservationsByZipCode } from "./historical-observations-by-reporting-area-by-zip-code.js";
    import { registerObservationsByBoundingBox } from "./observations-by-monitoring-site-by-geographic-bounding-box.js";
    
    export const registerTools = (server: McpServer): void => {
      registerContourMapsByBoundingBoxCombined(server);
      registerContourMapsByBoundingBoxOzone(server);
      registerContourMapsByBoundingBoxPM25(server);
      registerCurrentObservationsByZipCode(server);
      registerCurrentObservationsByLatLong(server);
      registerForecastByLatLong(server);
      registerForecastByZipCode(server);
      registerHistoricalObservationsByLatLong(server);
      registerHistoricalObservationsByZipCode(server);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but lacks critical details: it doesn't specify output format beyond 'AQI values and categories', mention rate limits, authentication requirements, error handling, or data freshness. The description implies a read-only operation but doesn't explicitly confirm safety or potential side effects.

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 front-loads the core purpose without unnecessary words. Every part earns its place by specifying the action, data type, and target, making it easy to scan and understand 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 4-parameter tool with no annotations and no output schema, the description is incomplete. It doesn't address behavioral aspects like data sources, accuracy, limitations (e.g., date ranges), or output structure. For a tool that likely returns structured environmental data, more context is needed to use it effectively without trial and error.

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?

Schema description coverage is 100%, so parameters are fully documented in the input schema. The description adds no additional parameter semantics beyond implying Zip code and date usage. It doesn't explain interactions between parameters (e.g., how distance affects results) or provide examples beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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 target ('for a reporting area by Zip code'), which is specific and actionable. However, it doesn't differentiate from sibling tools like 'get-historical-observations-by-reporting-area-by-lat-long' or 'get-current-observations-by-reporting-area-by-zip-code', which would require mentioning temporal scope (historical vs current) or 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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools or contextual factors like data availability, performance considerations, or prerequisites. Users must infer usage from the tool name alone, which is insufficient for optimal selection.

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