Skip to main content
Glama
sthossan

Weather & Prayer Times MCP Server

by sthossan
prayerTime.ts2.98 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import axios from "axios"; export function registerPrayerTimesTool(server: McpServer) { server.tool( "get_prayer_times", "Get prayer times for a city", { city: z.string().describe("City name").optional().default("Dhaka"), country: z.string().describe("Country code").optional().default("BD"), method: z.number().describe("Calculation method (0-99)").optional().default(1) }, async ({ city, country, method }) => { try { const response = await axios.get("https://api.aladhan.com/v1/timingsByCity", { params: { city: city, country: country, method: method, date: new Date().toISOString().split('T')[0] } }); const data = response.data; if (data.code !== 200) { return { content: [ { type: "text", text: `Error: ${data.data}` } ] }; } const timings = data.data.timings; const dateInfo = data.data.date; const location = `${data.data.meta.timezone}, ${data.data.meta.method.name}`; const prayerTimes = ` Prayer Times for ${city}, ${country} - ${dateInfo.readable} 📍 ${location} 🕒 Prayer Schedule: • Fajr: ${timings.Fajr} • Sunrise: ${timings.Sunrise} • Dhuhr: ${timings.Dhuhr} • Asr: ${timings.Asr} • Maghrib: ${timings.Maghrib} • Isha: ${timings.Isha} 📅 Hijri Date: ${dateInfo.hijri.date} (${dateInfo.hijri.day} ${dateInfo.hijri.month.en} ${dateInfo.hijri.year}) `.trim(); return { content: [ { type: "text", text: prayerTimes } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching prayer times: ${error instanceof Error ? error.message : 'Unknown error'}` } ] }; } } ); }

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/sthossan/mcp-server'

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