Skip to main content
Glama

get_locations

Retrieve all available cities and locations in Portugal for accessing weather forecasts and meteorological data from IPMA.

Instructions

Listar todas as cidades/locais disponíveis para previsão

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that fetches the list of locations from the IPMA API, groups them by district, and returns a formatted text response listing all available cities/locations.
    private async getLocations() {
      try {
        const response = await fetch(`${this.baseUrl}/distrits-islands.json`);
        const data = await response.json() as ApiResponse<Location>;
    
        let result = "📍 **Locais Disponíveis para Previsão**\n\n";
        
        // Agrupar por distrito/região
        const groupedByDistrict: { [key: number]: Location[] } = {};
        
        data.data.forEach((location: Location) => {
          if (!groupedByDistrict[location.idDistrito]) {
            groupedByDistrict[location.idDistrito] = [];
          }
          groupedByDistrict[location.idDistrito].push(location);
        });
    
        Object.values(groupedByDistrict).forEach((locations: Location[]) => {
          // Assumir que todas as localizações no grupo têm o mesmo distrito
          result += `**Região ${locations[0].idDistrito}:**\n`;
          locations.forEach((loc: Location) => {
            result += `• ${loc.local} (${loc.latitude}, ${loc.longitude})\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 locais: ${errorMessage}`);
      }
    }
  • Defines the input schema for the get_locations tool: an empty object (no parameters required). Also includes name and description.
    {
      name: "get_locations",
      description: "Listar todas as cidades/locais disponíveis para previsão",
      inputSchema: {
        type: "object",
        properties: {}
      }
    },
  • src/index.ts:215-216 (registration)
    Registers the tool handler by dispatching calls to the getLocations() method in the CallToolRequest handler.
    case "get_locations":
      return await this.getLocations();
  • TypeScript interface defining the structure of location data used in the getLocations handler.
    interface Location {
      idRegiao: number;
      idAreaAviso: string;
      idConcelho: number;
      globalIdLocal: number;
      latitude: string;
      idDistrito: number;
      local: string;
      longitude: string;
    }

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