Skip to main content
Glama

get_locations

Retrieve all available cities and locations in Portugal to access 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 main handler function for the 'get_locations' tool. Fetches location data from the IPMA API, groups locations by district, formats them into a markdown text response, and returns it in the MCP content format.
    async getLocations() { try { const response = await fetch(`${this.baseUrl}/distrits-islands.json`); const data = await response.json(); let result = "**Locais Disponíveis para Previsão**\n\n"; const groupedByDistrict = {}; data.data.forEach((location) => { if (!groupedByDistrict[location.idDistrito]) { groupedByDistrict[location.idDistrito] = []; } groupedByDistrict[location.idDistrito].push(location); }); Object.values(groupedByDistrict).forEach((locations) => { result += `**Região ${locations[0].idDistrito}:**\n`; locations.forEach((loc) => { 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}`); } }
  • src/index.js:74-81 (registration)
    Registers the 'get_locations' tool in the list of tools returned by ListToolsRequestSchema, including its name, description, and input schema.
    { name: "get_locations", description: "Listar todas as cidades/locais disponíveis para previsão", inputSchema: { type: "object", properties: {} } },
  • Defines the input schema for the 'get_locations' tool, which requires no parameters (empty properties).
    inputSchema: { type: "object", properties: {} }
  • Part of the CallToolRequestSchema handler that dispatches calls to the 'get_locations' tool by invoking the getLocations() method.
    case "get_locations": return await this.getLocations();

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