Skip to main content
Glama
prsantos-com

AirNow MCP Server

by prsantos-com

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

Retrieve real-time AQI values and categories for a specific reporting area using a Zip code. The tool also fetches nearby area data if no reporting area is associated with the provided Zip code. Supports multiple formats for data output.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
distanceNoIf no reporting area is associated with the Zip code, 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
zipCodeYesZip code to get the current observations for. Example: 94954

Implementation Reference

  • The handler function that executes the tool logic by calling the AirNow API helper and formatting the response.
    async (params) => {
      const result =
        await airnowApi.fetchCurrentObservationsByReportingAreaByZipCode(
          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 defining the input parameters: zipCode (required), format (enum), distance (optional).
    {
      zipCode: z
        .string()
        .describe(
          "Zip code to get the current observations for. Example: 94954"
        ),
      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, current observations from a nearby reporting area within this distance (in miles) will be returned, if available. Example: 150"
        ),
    },
  • Primary registration of the tool with MCP server, including name, description, schema, and handler.
    export const registerCurrentObservationsByZipCode = (server: McpServer): void => {
      server.tool(
        "get-current-observations-by-reporting-area-by-zip-code",
        "Get current AQI values and categories for a reporting area by Zip code.",
        {
          zipCode: z
            .string()
            .describe(
              "Zip code to get the current observations for. Example: 94954"
            ),
          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, 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.fetchCurrentObservationsByReportingAreaByZipCode(
              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,
              },
            ],
          };
        }
      );
    };
  • API helper function that constructs the AirNow API request for current observations by zip code and fetches the data.
    export async function fetchCurrentObservationsByReportingAreaByZipCode(params: Record<string, string>): Promise<string | null> {
      const endpoint = 'aq/observation/zipcode/current/';
      const queryParams = new URLSearchParams();
      queryParams.append('zipCode', params.zipCode);
      queryParams.append('format', params.format);
      if (params.distance) queryParams.append('distance', params.distance);
    
      return airnowGet(endpoint, queryParams);
    }
  • Secondary registration: import and invocation of the tool registrar within the tools index.
    import { registerCurrentObservationsByZipCode } from "./current-observations-by-reporting-area-by-zip-code.js";
    import { registerCurrentObservationsByLatLong } from "./current-observations-by-reporting-area-by-lat-long.js";
    import { registerForecastByLatLong } from "./forecast-by-lat-long.js";
    import { registerForecastByZipCode } from "./forecast-by-zip-code.js";
    import { registerHistoricalObservationsByLatLong } from "./historical-observations-by-reporting-area-by-lat-long.js";
    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);
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While it mentions what the tool returns ('current AQI values and categories'), it doesn't describe important behavioral aspects like error handling (what happens with invalid zip codes), rate limits, authentication requirements, or whether this is a read-only operation. The description is minimal and leaves key behavioral questions unanswered.

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 communicates the core functionality without unnecessary words. It's appropriately front-loaded with the main purpose. However, given the tool's complexity and lack of annotations, it might be too concise at the expense of needed behavioral context.

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?

For a tool with no annotations, no output schema, and multiple sibling alternatives, the description is insufficiently complete. It doesn't explain what 'reporting area' means in practice, doesn't clarify the relationship between zip codes and reporting areas, and provides no information about the response structure or format options despite the format parameter being required.

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?

With 100% schema description coverage, the input schema already provides comprehensive documentation for all three parameters. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it mentions 'by Zip code' which aligns with the zipCode parameter but provides no additional context about parameter usage, relationships, or constraints.

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 current AQI values and categories') and target resource ('for a reporting area by Zip code'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from its closest sibling 'get-current-observations-by-reporting-area-by-lat-long', which performs the same function but uses latitude/longitude instead of zip code.

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. With multiple sibling tools available (including forecast tools, historical observations, and lat-long variants), there's no indication of when zip code lookup is preferred over lat-long or when current observations are appropriate versus forecasts or historical data.

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