Skip to main content
Glama
icyrainz

XMLTV MCP Server

by icyrainz

get_channels

Retrieve all available TV channels from XMLTV feeds to access programming data and schedule information.

Instructions

Get list of all available TV channels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_channels' tool. Fetches cached XMLTV data and maps channels to an array of {id, name, icon} objects.
    async function getChannels() { const data = await getXmltvData(); return data.tv.channel.map(ch => ({ id: ch.id, name: ch["display-name"], icon: typeof ch.icon === 'object' ? ch.icon.src : undefined, })); }
  • The tool schema definition including name, description, and empty input schema (no parameters required).
    { name: "get_channels", description: "Get list of all available TV channels", inputSchema: { type: "object", properties: {}, }, },
  • src/index.ts:339-349 (registration)
    Registration in the CallToolRequestSchema handler: switch case that invokes getChannels() and formats response as JSON text.
    case "get_channels": { const channels = await getChannels(); return { content: [ { type: "text", text: JSON.stringify(channels, null, 2), }, ], }; }
  • src/index.ts:332-334 (registration)
    Handler for ListToolsRequestSchema that returns the tools list including 'get_channels'.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • Helper function to fetch, parse, and cache XMLTV data from the configured URL, used by getChannels.
    async function getXmltvData(): Promise<XmltvData> { const now = Date.now(); if (cache && (now - cache.timestamp) < CACHE_TTL) { return cache.data; } const response = await fetch(XMLTV_URL); if (!response.ok) { throw new Error(`Failed to fetch XMLTV: ${response.statusText}`); } const xmlText = await response.text(); const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "", }); const parsed = parser.parse(xmlText) as XmltvData; // Ensure arrays are always arrays (parser might return single object) if (parsed.tv.channel && !Array.isArray(parsed.tv.channel)) { parsed.tv.channel = [parsed.tv.channel]; } if (parsed.tv.programme && !Array.isArray(parsed.tv.programme)) { parsed.tv.programme = [parsed.tv.programme]; } cache = { data: parsed, timestamp: now }; return parsed; }

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/icyrainz/xmltv-mcp'

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