Skip to main content
Glama

Travel MCP

by Erredebe
airQuality.ts1.15 kB
import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; export function registerAirQuality(server: McpServer) { server.tool( "air-quality", "Get air quality data for a city using OpenAQ", { city: z.string().describe("City name"), }, async ({ city }) => { const url = `https://api.openaq.org/v2/latest?city=${encodeURIComponent(city)}&limit=1`; const ctrl = new AbortController(); const id = setTimeout(() => ctrl.abort(), 8000); try { const res = await fetch(url, { signal: ctrl.signal }); const data = await res.json(); const result = data.results && data.results[0] ? data.results[0] : {}; 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