obtener-clima
Retrieve real-time weather data for a specified city. Use this tool to quickly access accurate climate information for planning and analysis.
Instructions
Herramienta para obtener clima
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| city | Yes | Ciudad para obtener el clima |
Implementation Reference
- src/main.ts:24-31 (registration)Registers the "obtener-clima" tool with its input schema and handler function.server.registerTool( "obtener-clima", { description: "Herramienta para obtener clima", inputSchema: weatherInputSchema }, weatherToolHandler );
- src/tools/weatherTool.ts:7-9 (schema)Defines the Zod input schema for the weather tool, specifying the required 'city' parameter.export const weatherInputSchema = { city: z.string().describe("Ciudad para obtener el clima") };
- src/tools/weatherTool.ts:16-31 (handler)Implements the weatherToolHandler function that extracts the city, calls the weather 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}.` } ] }; }
- src/services/weatherService.ts:19-27 (helper)Provides the getWeather helper function that returns mock weather data for a given city (in production would call a real API).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" }; }