sonarr_get_calendar
Retrieve upcoming TV episodes from Sonarr to plan viewing schedules and manage media libraries. Specify days ahead to customize the calendar view.
Instructions
Get upcoming TV episodes from Sonarr
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days to look ahead (default: 7) |
Implementation Reference
- src/index.ts:1121-1130 (handler)Handler for sonarr_get_calendar: computes start/end dates based on optional 'days' param (default 7 days), calls SonarrClient.getCalendar API, returns JSON response.case "sonarr_get_calendar": { if (!clients.sonarr) throw new Error("Sonarr not configured"); const days = (args as { days?: number })?.days || 7; const start = new Date().toISOString().split('T')[0]; const end = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toISOString().split('T')[0]; const calendar = await clients.sonarr.getCalendar(start, end); return { content: [{ type: "text", text: JSON.stringify(calendar, null, 2) }], }; }
- src/index.ts:216-228 (registration)Tool registration in TOOLS array: defines name, description, and input schema for 'days' parameter (optional number). Added conditionally if Sonarr client configured.name: "sonarr_get_calendar", description: "Get upcoming TV episodes from Sonarr", inputSchema: { type: "object" as const, properties: { days: { type: "number", description: "Number of days to look ahead (default: 7)", }, }, required: [], }, },
- src/arr-client.ts:499-505 (handler)Core implementation in ArrClient.getCalendar (inherited by SonarrClient): constructs /calendar API endpoint with start/end params and fetches upcoming episodes.async getCalendar(start?: string, end?: string): Promise<unknown[]> { const params = new URLSearchParams(); if (start) params.append('start', start); if (end) params.append('end', end); const query = params.toString() ? `?${params.toString()}` : ''; return this.request<unknown[]>(`/calendar${query}`); }
- src/arr-client.ts:592-595 (helper)SonarrClient class definition, extends ArrClient providing Sonarr-specific methods and used by index.ts handler.export class SonarrClient extends ArrClient { constructor(config: ArrConfig) { super('sonarr', config); }
- src/index.ts:70-72 (registration)Instantiation of SonarrClient if SONARR_URL and SONARR_API_KEY env vars are set, required for tool availability.case 'sonarr': clients.sonarr = new SonarrClient(config); break;