get_marathon
Retrieve detailed marathon information including countdown timers and structured Schema.org data for specific race events.
Instructions
Get detailed information about a specific marathon including countdown and Schema.org data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Marathon ID, e.g. "tokyo2026", "boston2026", "berlin2026" |
Implementation Reference
- index.js:173-199 (handler)The `get_marathon` tool fetches detailed marathon information from the RunDida API and formats it into a text response with event details, weather, and course info.
server.tool( 'get_marathon', 'Get detailed information about a specific marathon including countdown and Schema.org data', { id: z.string().describe('Marathon ID, e.g. "tokyo2026", "boston2026", "berlin2026"') }, async ({ id }) => { const data = await fetchJSON(`${BASE_URL}/api/marathons/${id}.json`); const m = data.marathon; const raceDate = new Date(m.date); const now = new Date(); const daysUntil = Math.ceil((raceDate - now) / (1000 * 60 * 60 * 24)); let text = `## ${m.name.en}\n\nDate: ${m.date}\nCity: ${m.city}\n`; if (m.country) text += `Country/Region: ${m.country}\n`; text += `Timezone: ${m.timezone}\n`; text += `Days until race: ${daysUntil > 0 ? daysUntil : 'Race has passed'}\n`; if (m.weather) { text += `\n### Race Day Weather\nTemperature: ${m.weather.avgTempC}°C / ${m.weather.avgTempF}°F\n`; text += `Humidity: ${m.weather.humidity}% | Wind: ${m.weather.windKmh} km/h | Rain: ${m.weather.precipPct}%\n`; text += `Conditions: ${m.weather.conditions}\n`; } if (m.course) { text += `\n### Course Profile\nType: ${m.course.type} | Elevation: ${m.course.elevationGain}m | Terrain: ${m.course.terrain}\n`; text += `${m.course.profile}\n`; } text += `\nPage: ${m.links.page}\nCountdown: ${m.links.countdown}\n`; return { content: [{ type: 'text', text }] }; } );