Skip to main content
Glama

obtener-clima

Retrieve real-time weather data for any city using geographic coordinates. Designed for quick integration with the Said MCP server, enabling accurate and instant weather updates.

Instructions

Herramienta para obtener el clima en tiempo real

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYesCity name

Implementation Reference

  • main.ts:16-45 (handler)
    The async handler function that geocodes the city name using Open-Meteo geocoding API, fetches current weather data including temperature and precipitation, and returns it formatted as a JSON string in an MCP-compatible content block.
    async ({ city }) => { const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${city}&count=10&language=en&format=json`) const data = await response.json() if (data.length === 0) { return { content: [ { type: 'text', text: `No se pudo encontrar la información de ${city}` } ] } } const { latitude, longitude } = data.results[0] const getCurrentWeather = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&hourly=temperature_2m&current=temperature_2m,precipitation,rain`) const weatherData = await getCurrentWeather.json() return { content: [ { type: 'text', text: JSON.stringify(weatherData, null, 2) } ] } }
  • main.ts:13-15 (schema)
    Zod schema defining the input parameter 'city' as a required string.
    { city: z.string().describe('City name') },
  • main.ts:10-46 (registration)
    Registration of the 'obtener-clima' tool on the MCP server, specifying name, description, input schema, and inline handler function.
    server.tool( 'obtener-clima', 'Herramienta para obtener el clima en tiempo real', { city: z.string().describe('City name') }, async ({ city }) => { const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${city}&count=10&language=en&format=json`) const data = await response.json() if (data.length === 0) { return { content: [ { type: 'text', text: `No se pudo encontrar la información de ${city}` } ] } } const { latitude, longitude } = data.results[0] const getCurrentWeather = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&hourly=temperature_2m&current=temperature_2m,precipitation,rain`) const weatherData = await getCurrentWeather.json() return { content: [ { type: 'text', text: JSON.stringify(weatherData, null, 2) } ] } } )

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/JunLovin/weather-mcp'

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