get-archived-tasks
Retrieve archived tasks from Sunsama with pagination controls to manage large collections of completed or historical work items.
Instructions
Get archived tasks with optional pagination
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of tasks to return (defaults to 100) | |
| offset | No | Pagination offset (defaults to 0) |
Implementation Reference
- src/tools/task-tools.ts:78-105 (handler)The core handler implementation for the 'get-archived-tasks' tool. It uses pagination (offset/limit), fetches from client.getArchivedTasks, trims tasks, and returns formatted TSV with pagination metadata.export const getArchivedTasksTool = withTransportClient({ name: "get-archived-tasks", description: "Get archived tasks with optional pagination", parameters: getArchivedTasksSchema, execute: async ( { offset = 0, limit = 100 }: GetArchivedTasksInput, context: ToolContext, ) => { const requestedLimit = limit; const fetchLimit = requestedLimit + 1; const allTasks = await context.client.getArchivedTasks(offset, fetchLimit); const hasMore = allTasks.length > requestedLimit; const tasks = hasMore ? allTasks.slice(0, requestedLimit) : allTasks; const trimmedTasks = trimTasksForResponse(tasks); const paginationInfo = { offset, limit: requestedLimit, count: tasks.length, hasMore, nextOffset: hasMore ? offset + requestedLimit : null, }; return formatPaginatedTsvResponse(trimmedTasks, paginationInfo); }, });
- src/schemas.ts:32-39 (schema)Zod schema defining the input parameters for the tool: optional offset (>=0) and limit (1-1000).export const getArchivedTasksSchema = z.object({ offset: z.number().int().min(0).optional().describe( "Pagination offset (defaults to 0)", ), limit: z.number().int().min(1).max(1000).optional().describe( "Maximum number of tasks to return (defaults to 100)", ), });
- src/tools/task-tools.ts:406-426 (registration)Registers the getArchivedTasksTool as part of the taskTools array export.export const taskTools = [ // Query tools getTasksBacklogTool, getTasksByDayTool, getArchivedTasksTool, getTaskByIdTool, // Lifecycle tools createTaskTool, deleteTaskTool, // Update tools updateTaskCompleteTool, updateTaskSnoozeDateTool, updateTaskBacklogTool, updateTaskPlannedTimeTool, updateTaskNotesTool, updateTaskDueDateTool, updateTaskTextTool, updateTaskStreamTool, ];
- src/tools/index.ts:5-9 (registration)Final registration: spreads taskTools (including getArchivedTasksTool) into the allTools array, which is used for MCP server tool registration.export const allTools = [ ...userTools, ...taskTools, ...streamTools, ];
- src/tools/task-tools.ts:34-40 (helper)Imports helper functions like withTransportClient (wraps the handler), formatPaginatedTsvResponse (used in execute for output), and ToolContext type.import { formatJsonResponse, formatPaginatedTsvResponse, formatTsvResponse, withTransportClient, type ToolContext, } from "./shared.js";