Skip to main content
Glama
prsantos-com

AirNow MCP Server

by prsantos-com

get-forecast-by-lat-long

Retrieve current or historical air quality forecast data for a specific location using latitude and longitude. Access AQI values and categories in JSON, CSV, or XML formats for informed environmental decisions.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate of forecast. Format: YYYY-MM-DD. Example: 2012-02-01
distanceNoReturn a forecast from a nearby reporting area within this distance (in miles). 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 handler function for the get-forecast-by-lat-long tool. It calls the AirNow API helper and returns the result as text content or an error.
    async (params) => {
      const result = await airnowApi.fetchForecastByLatLong(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 schema defining the input parameters for the tool: latitude, longitude, optional date, format, and 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()
        .optional()
        .describe("Date of forecast. 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(
          "Return a forecast from a nearby reporting area within this distance (in miles). Example: 150"
        ),
    },
    async (params) => {
  • The registration function that calls server.tool() to register the get-forecast-by-lat-long tool with MCP server, including name, description, schema, and handler.
    export const registerForecastByLatLong = (server: McpServer): void => {
      server.tool(
        "get-forecast-by-lat-long",
        "Get current or historical forecasted 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()
            .optional()
            .describe("Date of forecast. 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(
              "Return a forecast from a nearby reporting area within this distance (in miles). Example: 150"
            ),
        },
        async (params) => {
          const result = await airnowApi.fetchForecastByLatLong(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,
              },
            ],
          };
        }
      );
    };
  • Invocation of the tool registration function within the main registerTools function.
    registerForecastByLatLong(server);
  • Core helper function implementing the API call to AirNow for fetching forecast by latitude and longitude, constructing query params and using shared airnowGet fetcher.
    export async function fetchForecastByLatLong(params: Record<string, string>): Promise<string | null> {
      const endpoint = 'aq/forecast/latlong/';
      const queryParams = new URLSearchParams();
      queryParams.append('latitude', params.latitude);
      queryParams.append('longitude', params.longitude);
      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);
    }
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 'current or historical forecasted AQI values and categories' but doesn't explain what 'forecasted' entails (e.g., time range, accuracy), how 'reporting area' is determined, or any limitations like rate limits or authentication needs. For a tool with no annotations, this is a significant gap in transparency.

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 functionality without unnecessary words. It directly states what the tool does, making it easy to parse and understand quickly. Every part of the sentence contributes to clarifying the tool's purpose.

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

Completeness3/5

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

Given the complexity (5 parameters, no output schema, no annotations), the description is incomplete. It covers the basic purpose but lacks usage guidelines, behavioral details, and output information. While the schema handles parameters well, the description doesn't compensate for missing annotations or output schema, leaving gaps in overall context.

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 adds minimal value beyond the input schema, which has 100% coverage with detailed parameter descriptions. It implies latitude/longitude are used to locate a 'reporting area' and mentions 'current or historical' (hinting at the 'date' parameter), but doesn't elaborate on parameter interactions or semantics. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance understanding.

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 tool's purpose: 'Get current or historical forecasted AQI values and categories for a reporting area by latitude and longitude.' It specifies the verb ('Get'), resource ('forecasted AQI values and categories'), and mechanism ('by latitude and longitude'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from siblings like 'get-forecast-by-zip-code' or 'get-current-observations-by-reporting-area-by-lat-long', 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. It doesn't mention siblings like 'get-forecast-by-zip-code' for zip-based queries or 'get-current-observations-by-reporting-area-by-lat-long' for non-forecast data, nor does it specify prerequisites or exclusions. This leaves the agent without context for tool 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