sonarr_get_queue
Retrieve the Sonarr download queue with pagination. Use limit to control item count and offset to skip results.
Instructions
Get Sonarr download queue. Supports pagination with limit and offset.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of queue items to return (default: 25, max: 100) | |
| offset | No | Number of queue items to skip before returning results (default: 0) |
Implementation Reference
- src/index.ts:1505-1508 (handler)Handler for sonarr_get_queue tool call. Checks Sonarr is configured, then delegates to the getPaginatedQueue helper function.
case "sonarr_get_queue": { if (!clients.sonarr) throw new Error("Sonarr not configured"); return jsonText(await getPaginatedQueue(clients.sonarr, args as { limit?: number; offset?: number })); } - src/index.ts:245-261 (schema)Tool registration/schema definition for sonarr_get_queue with input schema specifying optional limit and offset parameters.
name: "sonarr_get_queue", description: "Get Sonarr download queue. Supports pagination with limit and offset.", inputSchema: { type: "object" as const, properties: { limit: { type: "number", description: "Maximum number of queue items to return (default: 25, max: 100)", }, offset: { type: "number", description: "Number of queue items to skip before returning results (default: 0)", }, }, required: [], }, }, - src/index.ts:1085-1128 (helper)Helper function that fetches all pages of the queue from the API client, slices based on limit/offset, and formats the response with pagination metadata.
async function getPaginatedQueue( client: QueueCapableClient, args: { limit?: number; offset?: number } | undefined ) { const limit = Math.min(Math.max(Math.floor(args?.limit ?? 25), 1), 100); const offset = Math.max(Math.floor(args?.offset ?? 0), 0); const pageSize = 100; const records = []; let totalRecords = 0; let page = 1; while (true) { const queuePage = await client.getQueue(page, pageSize); totalRecords = queuePage.totalRecords; records.push(...queuePage.records); if (records.length >= totalRecords || queuePage.records.length === 0) { break; } page += 1; } const items = records.slice(offset, offset + limit).map((q) => ({ title: q.title, status: q.status, progress: q.size > 0 ? ((1 - q.sizeleft / q.size) * 100).toFixed(1) + "%" : "unknown", timeLeft: q.timeleft, downloadClient: q.downloadClient, protocol: q.protocol, trackedDownloadStatus: q.trackedDownloadStatus, trackedDownloadState: q.trackedDownloadState, })); return { total: totalRecords, returned: items.length, offset, limit, hasMore: offset + items.length < totalRecords, nextOffset: offset + items.length < totalRecords ? offset + items.length : null, items, }; } - src/arr-client.ts:429-437 (helper)Base API client method on ArrClient that calls the /queue endpoint with pagination parameters. Shared by SonarrClient, RadarrClient, and LidarrClient.
async getQueue(page = 1, pageSize = 100): Promise<{ records: QueueItem[]; totalRecords: number }> { const params = new URLSearchParams({ includeUnknownSeriesItems: "true", includeUnknownMovieItems: "true", page: String(page), pageSize: String(pageSize), }); return this.request<{ records: QueueItem[]; totalRecords: number }>(`/queue?${params.toString()}`); } - src/arr-client.ts:32-47 (schema)Type definition for queue items returned by the API, used in getQueue and getPaginatedQueue.
export interface QueueItem { id: number; title: string; status: string; trackedDownloadStatus: string; trackedDownloadState: string; statusMessages: Array<{ title: string; messages: string[] }>; downloadId: string; protocol: string; downloadClient: string; outputPath: string; sizeleft: number; size: number; timeleft: string; estimatedCompletionTime: string; }