Skip to main content
Glama
prsantos-com

AirNow MCP Server

by prsantos-com

get-forecast-by-zip-code

Retrieve current or historical air quality forecast data by Zip code, specifying format and optional date or distance. Access AQI values and categories for informed decision-making.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate to get the forecast for. Format: YYYY-MM-DD. Example: 2012-02-01
distanceNoDistance in miles to search for the forecast. Example: 150
formatYesFormat of the payload file returned. Example: application/json
zipCodeYesZip code to get the forecast for. Example: 94954

Implementation Reference

  • The MCP tool handler function that invokes the AirNow API helper to fetch forecast data by zip code and formats the response as MCP content.
      async (params) => {
        const result = await airnowApi.fetchForecastByZipCode(params);
        if (result === null) {
          return {
            content: [
              {
                type: "text",
                text: "Failed to fetch forecast data from AirNow API.",
              },
            ],
            isError: true,
          };
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Zod-based input schema defining parameters for the get-forecast-by-zip-code tool: zipCode (string), date (optional string), format (enum), distance (optional string).
    {
      zipCode: z
        .string()
        .describe("Zip code to get the forecast for. Example: 94954"),
      date: z
        .string()
        .optional()
        .describe(
          "Date to get the forecast 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("Distance in miles to search for the forecast. Example: 150"),
    },
  • Exported registration function specific to this tool, called from tools/index.ts to register the tool on the MCP server.
    export const registerForecastByZipCode = (server: McpServer): void => {
      server.tool(
        "get-forecast-by-zip-code",
        "Get current or historical forecasted AQI values and categories for a reporting area by Zip code.",
        {
          zipCode: z
            .string()
            .describe("Zip code to get the forecast for. Example: 94954"),
          date: z
            .string()
            .optional()
            .describe(
              "Date to get the forecast 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("Distance in miles to search for the forecast. Example: 150"),
        },
        async (params) => {
          const result = await airnowApi.fetchForecastByZipCode(params);
          if (result === null) {
            return {
              content: [
                {
                  type: "text",
                  text: "Failed to fetch forecast data from AirNow API.",
                },
              ],
              isError: true,
            };
          }
          return {
            content: [
              {
                type: "text",
                text: result,
              },
            ],
          };
        }
      );
    }
  • Core helper function that constructs the API request to AirNow's forecast/zipcode endpoint and fetches the data using the shared airnowGet function.
    export async function fetchForecastByZipCode(params: Record<string, string>): Promise<string | null> {
      const endpoint = 'aq/forecast/zipcode/';
      const queryParams = new URLSearchParams();
      queryParams.append('zipCode', params.zipCode);
      queryParams.append('format', params.format);
      if (params.date) queryParams.append('date', params.date);
      if (params.distance) queryParams.append('distance', params.distance);
    
      return airnowGet(endpoint, queryParams);
    }
  • Invocation of the tool's registration function within the central registerTools function.
    registerForecastByZipCode(server);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool retrieves forecasted AQI data but lacks details on permissions, rate limits, data freshness, error handling, or response format. This is inadequate for a tool with potential external API calls and data sensitivity.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads key information (get forecast, AQI, by Zip code). It avoids redundancy but could be slightly more structured by separating current vs. historical aspects.

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 no annotations and no output schema, the description is incomplete. It doesn't explain return values (e.g., AQI categories, timestamps), error conditions, or dependencies like API availability. For a tool with environmental data implications, this leaves significant gaps for an AI agent.

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 the schema fully documents all parameters (date, distance, format, zipCode). The description adds no additional parameter semantics beyond implying AQI-related data, which doesn't compensate for schema completeness. Baseline 3 is appropriate as the 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'), the resource ('forecasted AQI values and categories'), and the target ('by Zip code'), with specificity about current/historical data. However, it doesn't explicitly differentiate from sibling tools like 'get-forecast-by-lat-long' or 'get-current-observations-by-reporting-area-by-zip-code', which would require a 5.

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 like 'get-forecast-by-lat-long' or observation-based tools. It mentions 'current or historical' but doesn't specify criteria for choosing between them or exclusions, leaving the agent without contextual usage instructions.

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