Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe task ID of the original video to extend (from a previous generation)
promptYesText prompt describing how to extend the video (what should happen next)
model_nameNoModel version to use for extension (default: kling-v2-master)
durationNoExtension duration (fixed at 5 seconds)
modeNoVideo generation mode (default: standard)

Implementation Reference

  • 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;
      }
    }
  • 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'],
      },
    },
  • 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.`,
          },
        ],
      };
    }
  • 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'],
      },
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses key behavioral traits: it's a generative extension tool ('generating new content'), mentions the AI provider ('Kling AI'), and specifies the duration range ('4-5 seconds'). However, it doesn't cover important aspects like rate limits, authentication needs, cost implications, or what the output looks like (e.g., returns a new task ID).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized (three sentences) and front-loaded with the core purpose. Every sentence adds value: first states the action, second explains the mechanism, third provides usage context. It could be slightly more concise by combining ideas, but there's minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a generative tool with 5 parameters, 100% schema coverage, but no annotations or output schema, the description is adequate but has gaps. It covers the what and why well, but lacks details on behavioral constraints (e.g., rate limits), output format, or error conditions. The context is complete enough for basic use but not for robust agent operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing full parameter documentation. The description adds minimal value beyond the schema, only implying that 'task_id' refers to 'a previous generation' and 'prompt' guides 'what should happen next'. It doesn't explain parameter interactions or provide additional context, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Extend a video by 4-5 seconds using Kling AI') and resource ('a video'), distinguishing it from siblings like generate_video (create new) or apply_video_effect (modify existing). It explains the functional outcome ('continue a video beyond its original ending, generating new content that seamlessly follows from the last frame').

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Perfect for creating longer sequences or adding additional scenes to existing videos'), but doesn't explicitly state when not to use it or name alternatives among siblings (e.g., generate_video for new videos, apply_video_effect for modifications). The guidance is helpful but lacks explicit exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/199-mcp/mcp-kling'

If you have feedback or need assistance with the MCP directory API, please join our Discord server