Skip to main content
Glama

Travel MCP

by Erredebe
reverseGeocode.ts1.37 kB
import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; export function registerReverseGeocode(server: McpServer) { server.tool( "reverse-geocode", "Convert coordinates to an address using OpenStreetMap Nominatim", { lat: z.string().describe("Latitude"), lon: z.string().describe("Longitude"), }, async ({ lat, lon }) => { const url = `https://nominatim.openstreetmap.org/reverse?format=json&lat=${encodeURIComponent(lat)}&lon=${encodeURIComponent(lon)}`; const ctrl = new AbortController(); const id = setTimeout(() => ctrl.abort(), 8000); try { const res = await fetch(url, { headers: { "User-Agent": "mcp/1.0" }, signal: ctrl.signal, }); const data = await res.json(); const result = { display_name: data.display_name, address: data.address, }; return { content: [ { type: "text", text: JSON.stringify(result, 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