list_tasks
View and filter Kling AI video generation tasks by status, date range, or pagination to monitor progress and access task history.
Instructions
List all your Kling AI generation tasks with filtering options. View task history, check statuses, and filter by date range or status. Supports pagination for browsing through large task lists.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (default: 1) | |
| page_size | No | Number of tasks per page (default: 10, max: 100) | |
| status | No | Filter tasks by status | |
| start_time | No | Filter tasks created after this time (ISO 8601 format) | |
| end_time | No | Filter tasks created before this time (ISO 8601 format) |
Implementation Reference
- src/kling-client.ts:481-501 (handler)Core handler function that executes the Kling API call to list tasks with optional filtering and pagination parameters.async listTasks(params?: TaskListParams): Promise<any> { const path = '/v1/task/list'; const queryParams = { page: params?.page || 1, page_size: params?.page_size || 10, ...(params?.status && { status: params.status }), ...(params?.start_time && { start_time: params.start_time }), ...(params?.end_time && { end_time: params.end_time }), }; try { const response = await this.axiosInstance.get(path, { params: queryParams }); return response.data.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Kling API error: ${error.response?.data?.message || error.message}`); } throw error; } }
- src/kling-client.ts:109-115 (schema)Type definition for the input parameters of the listTasks tool.export interface TaskListParams { page?: number; page_size?: number; status?: 'submitted' | 'processing' | 'succeed' | 'failed'; start_time?: string; end_time?: string; }
- src/index.ts:431-464 (registration)Tool registration in the TOOLS array, including name, description, and input schema.{ name: 'list_tasks', description: 'List all your Kling AI generation tasks with filtering options. View task history, check statuses, and filter by date range or status. Supports pagination for browsing through large task lists.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)', minimum: 1, }, page_size: { type: 'number', description: 'Number of tasks per page (default: 10, max: 100)', minimum: 1, maximum: 100, }, status: { type: 'string', enum: ['submitted', 'processing', 'succeed', 'failed'], description: 'Filter tasks by status', }, start_time: { type: 'string', description: 'Filter tasks created after this time (ISO 8601 format)', }, end_time: { type: 'string', description: 'Filter tasks created before this time (ISO 8601 format)', }, }, required: [], }, },
- src/index.ts:752-792 (handler)MCP server handler for the 'list_tasks' tool call, which invokes klingClient.listTasks and formats the response as text.case 'list_tasks': { const params: TaskListParams = { page: args.page as number, page_size: args.page_size as number, status: args.status as 'submitted' | 'processing' | 'succeed' | 'failed', start_time: args.start_time as string, end_time: args.end_time as string, }; const taskList = await klingClient.listTasks(params); let tasksText = `Kling AI Task List (Page ${params.page || 1}):\n`; tasksText += `\nTotal Tasks: ${taskList.total || 0}`; if (taskList.tasks && taskList.tasks.length > 0) { tasksText += '\n\nTasks:'; taskList.tasks.forEach((task: any, index: number) => { tasksText += `\n\n${index + 1}. Task ID: ${task.task_id}`; tasksText += `\n Type: ${task.task_type || 'N/A'}`; tasksText += `\n Status: ${task.task_status}`; tasksText += `\n Created: ${new Date(task.created_at * 1000).toLocaleString()}`; if (task.updated_at) { tasksText += `\n Updated: ${new Date(task.updated_at * 1000).toLocaleString()}`; } if (task.model_name) { tasksText += `\n Model: ${task.model_name}`; } }); } else { tasksText += '\n\nNo tasks found.'; } return { content: [ { type: 'text', text: tasksText, }, ], }; }