Skip to main content
Glama

obtener-clima

Retrieve current weather data for any specified city using this API tool. Get temperature, conditions, and forecasts to integrate weather information into applications or workflows.

Instructions

Herramienta para obtener clima

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYesCiudad para obtener el clima

Implementation Reference

  • The main handler function for the "obtener-clima" tool. It extracts the city from params, fetches weather data using getWeather service, and returns a formatted MCP response.
    export async function weatherToolHandler(params: any) { const { city } = params; // Utilizamos el servicio de clima const weatherData = await getWeather(city); // Devolvemos el resultado formateado para MCP return { content: [ { type: "text" as const, text: `El clima en ${weatherData.city} es ${weatherData.condition} con una temperatura de ${weatherData.temperature}.` } ] }; }
  • Input schema for the "obtener-clima" tool, defining the required 'city' parameter using Zod.
    export const weatherInputSchema = { city: z.string().describe("Ciudad para obtener el clima") };
  • src/main.ts:24-31 (registration)
    Registration of the "obtener-clima" tool in the MCP server, linking the name, description, input schema, and handler.
    server.registerTool( "obtener-clima", { description: "Herramienta para obtener clima", inputSchema: weatherInputSchema }, weatherToolHandler );
  • Helper function that provides mock weather data for a given city, used by the tool handler.
    export async function getWeather(city: string): Promise<WeatherData> { // En un caso real, aquí se haría una llamada a una API de clima // Por ahora, devolvemos datos estáticos return { city, temperature: "25°C", condition: "soleado" }; }

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/mcgiverdev/mcp-api-v1'

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