Skip to main content
Glama

Travel MCP

by Erredebe
fetchWeather.ts1.28 kB
import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; export function registerFetchWeather(server: McpServer) { server.tool( "fetch-weather", "Fetch weather data for a given longitude and latitude", { lat: z.string().describe("Latitude"), lon: z.string().describe("Longitude"), }, async ({ lat, lon }) => { const ctrl = new AbortController(); const id = setTimeout(() => ctrl.abort(), 8000); try { const weatherResponse = await fetch( `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&hourly=temperature_2m&current=temperature_2m,precipitation,is_day,relative_humidity_2m,rain,wind_speed_10m`, { signal: ctrl.signal } ); const weatherData = await weatherResponse.json(); return { content: [ { type: "text", text: JSON.stringify(weatherData, null, 2), }, ], }; } catch (err: any) { return { content: [ { type: "text", text: JSON.stringify({ error: err.message }), }, ], }; } finally { clearTimeout(id); } } ); }

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/Erredebe/travel-mcp'

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