Skip to main content
Glama

get_uv_forecast

Get UV index forecasts for Portugal to plan outdoor activities safely and monitor sun exposure risks using data from IPMA weather services.

Instructions

Obter previsão do índice UV

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that fetches UV forecast data from the IPMA API, maps global IDs to location names, groups data by date, categorizes UV levels, and formats a markdown response.
    private async getUVForecast() {
      try {
        const response = await fetch(`${this.baseUrl}/forecast/meteorology/uv/uv.json`);
        const data = await response.json() as UVData[];
    
        if (!Array.isArray(data) || data.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "☀️ Não há dados de UV disponíveis no momento."
              }
            ]
          };
        }
    
        // Obter locais para mapear globalIdLocal para nomes
        const locationsResponse = await fetch(`${this.baseUrl}/distrits-islands.json`);
        const locationsData = await locationsResponse.json() as ApiResponse<Location>;
        
        const locationMap = locationsData.data.reduce((acc: any, loc: Location) => {
          acc[loc.globalIdLocal] = loc.local;
          return acc;
        }, {});
    
        let result = "☀️ **Previsão do Índice UV**\n\n";
        
        // Agrupar por data
        const uvByDate: { [key: string]: UVData[] } = {};
        data.forEach((uvData: UVData) => {
          if (!uvByDate[uvData.data]) {
            uvByDate[uvData.data] = [];
          }
          uvByDate[uvData.data].push(uvData);
        });
    
        Object.keys(uvByDate).slice(0, 3).forEach((date: string) => {
          result += `📅 **${date}**\n`;
          
          uvByDate[date].slice(0, 10).forEach((uv: UVData) => {
            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}`);
      }
    }
  • src/index.ts:189-196 (registration)
    Tool registration definition in the ListTools handler, specifying name, description, and empty input schema.
    {
      name: "get_uv_forecast",
      description: "Obter previsão do índice UV",
      inputSchema: {
        type: "object",
        properties: {}
      }
    }
  • src/index.ts:219-220 (registration)
    Dispatcher case in the CallToolRequestSchema handler that routes calls to the getUVForecast method.
    case "get_uv_forecast":
      return await this.getUVForecast();
  • Input schema for the get_uv_forecast tool, which requires no parameters.
    inputSchema: {
      type: "object",
      properties: {}
    }
  • TypeScript interface defining the structure of UV forecast data returned from the IPMA API.
    interface UVData {
      data: string;
      globalIdLocal: number;
      iUv: string;
      intervaloHora: string;
    }
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 states the tool gets a UV forecast but doesn't describe what that entails—e.g., whether it returns current or future data, if it requires location input (despite having 0 parameters), potential rate limits, or authentication needs. This leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

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 ('Obter previsão do índice UV') that directly states the tool's purpose without any waste. It's front-loaded and appropriately sized for a simple tool, making it easy to parse quickly. Every word earns its place by conveying the essential action and resource.

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 lack of annotations and output schema, the description is incomplete for a tool that might have behavioral complexities. It doesn't explain what the UV forecast includes (e.g., values, times, locations) or how it differs from sibling tools like 'get_weather_forecast'. For a tool with potential contextual nuances among weather-related siblings, more detail is needed to ensure the agent can use it correctly.

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 parameter 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 is adequate. However, it doesn't differentiate from sibling tools like 'get_weather_forecast' or 'get_weather_warnings', leaving ambiguity about scope boundaries. The purpose is understandable but lacks specificity about what distinguishes this UV forecast from other weather-related tools.

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 siblings like 'get_weather_forecast' and 'get_weather_warnings', there's no indication of whether this tool is for a specific location, time frame, or detail level. It lacks explicit when/when-not instructions or named alternatives, leaving usage context entirely implicit.

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/DiogoAzevedo03/ipma-mcp-server'

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