Skip to main content
Glama

marathon_countdown

Calculate the remaining time until a specific marathon event starts using its unique identifier.

Instructions

Get a countdown to a specific marathon event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesMarathon ID, e.g. "tokyo2026", "boston2026"

Implementation Reference

  • The handler function and registration for the 'marathon_countdown' tool. It fetches marathon data from an API and calculates the time remaining until the race date.
    // Tool: marathon_countdown
    server.tool(
      'marathon_countdown',
      'Get a countdown to a specific marathon event',
      { id: z.string().describe('Marathon ID, e.g. "tokyo2026", "boston2026"') },
      async ({ id }) => {
        const data = await fetchJSON(`${BASE_URL}/api/marathons/${id}.json`);
        const m = data.marathon;
        const raceDate = new Date(m.date + 'T00:00:00');
        const now = new Date();
        const diff = raceDate - now;
    
        if (diff <= 0) {
          return { content: [{ type: 'text', text: `${m.name.en} has already taken place on ${m.date}.` }] };
        }
    
        const days = Math.floor(diff / (1000 * 60 * 60 * 24));
        const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    
        let text = `${m.name.en} Countdown\n\n`;
        text += `${days} days, ${hours} hours until race day\n`;
        text += `Date: ${m.date}\nCity: ${m.city}\n`;
        text += `\nLive countdown: ${m.links.countdown}`;
        return { content: [{ type: 'text', text }] };
      }

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/XWeaponX7/rundida-mcp'

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