extend_video
Add 4-5 seconds to existing videos using AI, generating new content that continues from the last frame to create longer sequences or additional scenes.
Instructions
Extend a video by 4-5 seconds using Kling AI. This feature allows you to continue a video beyond its original ending, generating new content that seamlessly follows from the last frame. Perfect for creating longer sequences or adding additional scenes to existing videos.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The task ID of the original video to extend (from a previous generation) | |
| prompt | Yes | Text prompt describing how to extend the video (what should happen next) | |
| model_name | No | Model version to use for extension (default: kling-v2-master) | |
| duration | No | Extension duration (fixed at 5 seconds) | |
| mode | No | Video generation mode (default: standard) |
Implementation Reference
- src/kling-client.ts:249-269 (handler)Core implementation of the extend_video tool: sends POST request to Kling AI /v1/video/extension endpoint with task_id and prompt to extend existing video.
async extendVideo(request: VideoExtensionRequest): Promise<{ task_id: string }> { const path = '/v1/video/extension'; const body: any = { task_id: request.task_id, prompt: request.prompt, duration: request.duration || '5', mode: request.mode || 'standard', model_name: request.model_name || 'kling-v2-master', // V2-master is default }; try { const response = await this.axiosInstance.post(path, body); 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:56-62 (schema)TypeScript interface defining input parameters for video extension request.
export interface VideoExtensionRequest { task_id: string; prompt: string; model_name?: 'kling-v1' | 'kling-v1.5' | 'kling-v1.6' | 'kling-v2-master'; duration?: '5'; mode?: 'standard' | 'professional'; } - src/index.ts:224-256 (registration)MCP tool registration in TOOLS array, including name, description, and JSON schema for input validation.
{ name: 'extend_video', description: 'Extend a video by 4-5 seconds using Kling AI. This feature allows you to continue a video beyond its original ending, generating new content that seamlessly follows from the last frame. Perfect for creating longer sequences or adding additional scenes to existing videos.', inputSchema: { type: 'object', properties: { task_id: { type: 'string', description: 'The task ID of the original video to extend (from a previous generation)', }, prompt: { type: 'string', description: 'Text prompt describing how to extend the video (what should happen next)', }, model_name: { type: 'string', enum: ['kling-v1', 'kling-v1.5', 'kling-v1.6', 'kling-v2-master'], description: 'Model version to use for extension (default: kling-v2-master)', }, duration: { type: 'string', enum: ['5'], description: 'Extension duration (fixed at 5 seconds)', }, mode: { type: 'string', enum: ['standard', 'professional'], description: 'Video generation mode (default: standard)', }, }, required: ['task_id', 'prompt'], }, }, - src/index.ts:558-577 (handler)MCP server request handler (CallToolRequestSchema) that validates arguments, calls KlingClient.extendVideo, and formats response.
case 'extend_video': { const extendRequest = { task_id: args.task_id as string, prompt: args.prompt as string, model_name: (args.model_name as 'kling-v1' | 'kling-v1.5' | 'kling-v1.6' | 'kling-v2-master' | undefined) || 'kling-v2-master', duration: '5' as const, mode: (args.mode as 'standard' | 'professional') || 'standard', }; const result = await klingClient.extendVideo(extendRequest); return { content: [ { type: 'text', text: `Video extension started successfully!\nTask ID: ${result.task_id}\n\nThe video will be extended by approximately 5 seconds.\nUse the check_video_status tool with this task ID to check the progress.`, }, ], }; } - src/index.ts:227-256 (schema)JSON schema in tool registration for input validation in MCP protocol.
inputSchema: { type: 'object', properties: { task_id: { type: 'string', description: 'The task ID of the original video to extend (from a previous generation)', }, prompt: { type: 'string', description: 'Text prompt describing how to extend the video (what should happen next)', }, model_name: { type: 'string', enum: ['kling-v1', 'kling-v1.5', 'kling-v1.6', 'kling-v2-master'], description: 'Model version to use for extension (default: kling-v2-master)', }, duration: { type: 'string', enum: ['5'], description: 'Extension duration (fixed at 5 seconds)', }, mode: { type: 'string', enum: ['standard', 'professional'], description: 'Video generation mode (default: standard)', }, }, required: ['task_id', 'prompt'], }, },