Skip to main content
Glama

get_uv_forecast

Retrieve UV index forecasts for locations in Portugal to plan outdoor activities and manage sun exposure risks.

Instructions

Obter previsão do índice UV

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'get_uv_forecast' tool. It fetches UV forecast data from the IPMA API, resolves location names, groups data by date, limits to recent dates and locations, categorizes UV levels (Baixo, Moderado, Alto, Muito Alto, Extremo), formats a markdown report, and returns it as MCP text content. Handles errors with McpError.
    async getUVForecast() {
      try {
        const response = await fetch(`${this.baseUrl}/forecast/meteorology/uv/uv.json`);
        const data = await response.json();
    
        if (!Array.isArray(data) || data.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "Não há dados de UV disponíveis no momento."
              }
            ]
          };
        }
    
        const locationsResponse = await fetch(`${this.baseUrl}/distrits-islands.json`);
        const locationsData = await locationsResponse.json();
        
        const locationMap = locationsData.data.reduce((acc, loc) => {
          acc[loc.globalIdLocal] = loc.local;
          return acc;
        }, {});
    
        let result = "**Previsão do Índice UV**\n\n";
        
        const uvByDate = {};
        data.forEach((uvData) => {
          if (!uvByDate[uvData.data]) {
            uvByDate[uvData.data] = [];
          }
          uvByDate[uvData.data].push(uvData);
        });
    
        Object.keys(uvByDate).slice(0, 3).forEach((date) => {
          result += `**${date}**\n`;
          
          uvByDate[date].slice(0, 10).forEach((uv) => {
            const locationName = locationMap[uv.globalIdLocal] || `Local ${uv.globalIdLocal}`;
            const uvLevel = parseFloat(uv.iUv);
            let uvCategory = "";
            
            if (uvLevel <= 2) uvCategory = "Baixo";
            else if (uvLevel <= 5) uvCategory = "Moderado";
            else if (uvLevel <= 7) uvCategory = "Alto";
            else if (uvLevel <= 10) uvCategory = "Muito Alto";
            else uvCategory = "Extremo";
            
            result += `• ${locationName}: UV ${uv.iUv} (${uvCategory}) - ${uv.intervaloHora}\n`;
          });
          result += "\n";
        });
    
        return {
          content: [
            {
              type: "text",
              text: result
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new McpError(ErrorCode.InternalError, `Erro ao obter previsão UV: ${errorMessage}`);
      }
    }
  • Input schema definition for the 'get_uv_forecast' tool, specifying an object with no properties (no input parameters required).
    inputSchema: {
      type: "object",
      properties: {}
    }
  • src/index.js:90-97 (registration)
    Registration of the 'get_uv_forecast' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: "get_uv_forecast",
      description: "Obter previsão do índice UV",
      inputSchema: {
        type: "object",
        properties: {}
      }
    }
  • src/index.js:118-119 (registration)
    Dispatch registration in the CallToolRequestSchema handler's switch statement, mapping the tool name to the getUVForecast method call.
    case "get_uv_forecast":
      return await this.getUVForecast();
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 but offers minimal information. It states the tool gets UV forecasts but doesn't describe what data is returned (e.g., numerical values, risk levels, timeframes), whether it requires location input (though parameters are empty), or any limitations like rate limits or data sources. The description is too vague to guide the agent on what to expect from the tool's behavior.

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, concise sentence ('Obter previsão do índice UV') that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action. However, it could be more structured by including key details like scope or output, but given its brevity, it efficiently communicates the basic intent.

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 forecasting tool with no annotations, no output schema, and sibling tools like 'get_weather_forecast', the description is incomplete. It doesn't explain what the UV forecast includes (e.g., values, units, time periods), how it differs from weather forecasts, or what the return format is. For a tool that likely provides detailed data, this leaves significant gaps for the agent to understand its full context.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so there are no parameters to document. The description doesn't need to compensate for any gaps, and it appropriately doesn't mention parameters. A baseline of 4 is applied since no parameter information is required, and the description doesn't add unnecessary details.

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

Purpose3/5

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

The description 'Obter previsão do índice UV' clearly states the action ('Obter' - Get) and resource ('previsão do índice UV' - UV index forecast), which establishes the basic purpose. However, it doesn't differentiate this tool from its sibling 'get_weather_forecast' or specify what kind of UV forecast it provides (current, daily, hourly, location-specific). The purpose is understandable but lacks specificity about scope and differentiation.

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_weather_forecast' (which might include UV data) or other weather-related siblings. There's no mention of prerequisites, context for UV forecasting needs, or exclusions. The agent must infer usage from the tool name alone without any explicit direction.

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

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/brandao-20/mcp_server_ipma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server