get_now_playing
Retrieve currently airing TV programmes across all channels from XMLTV feeds to monitor live broadcasts and check what's on now.
Instructions
Get currently playing programmes on all channels
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:113-144 (handler)The getNowPlaying function implements the core logic to retrieve currently playing programmes across all channels by parsing XMLTV data and checking the current time against programme start and stop times.async function getNowPlaying() { const data = await getXmltvData(); const now = new Date(); const nowPlaying = data.tv.channel.map(channel => { const currentProgramme = data.tv.programme.find(prog => { if (prog.channel !== channel.id) return false; const start = parseXmltvDate(prog.start); const stop = parseXmltvDate(prog.stop); return now >= start && now < stop; }); return { channel: { id: channel.id, name: channel["display-name"], }, programme: currentProgramme ? { title: currentProgramme.title, subtitle: currentProgramme["sub-title"], description: currentProgramme.desc, start: currentProgramme.start, stop: currentProgramme.stop, episodeNum: Array.isArray(currentProgramme["episode-num"]) ? currentProgramme["episode-num"][0] : currentProgramme["episode-num"], } : null, }; }); return nowPlaying; }
- src/index.ts:272-279 (schema)Tool schema definition including name, description, and empty input schema (no parameters required).{ name: "get_now_playing", description: "Get currently playing programmes on all channels", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:351-361 (registration)MCP server request handler switch case that registers and invokes the get_now_playing tool by calling the getNowPlaying function and returning JSON-formatted results.case "get_now_playing": { const nowPlaying = await getNowPlaying(); return { content: [ { type: "text", text: JSON.stringify(nowPlaying, null, 2), }, ], }; }