Skip to main content

Overview

Use the Video MCP server from your ATXP-powered agent to create videos based on a prompt.

Example prompts

  • “Create a video of a cat riding a horse. Use a realistic style.”
  • “Create a video of a child and a puppy.”

Tools

Request text-to-video generation based on the given user prompt. After requesting the video, use the waitForVideo tool to wait for completion and get the resulting video. The status will be “success” and the task ID will be returned.

Arguments

Accepts a JSON object with the following properties:
userPrompt
string
required
The natural language description of the video to generate

Response

Returns a JSON object with the following properties:
status
string
The status of the video generation operation. Returns “success” when the video is generated successfully.
taskId
string
The task ID of the video generation operation.
Wait for a previously requested video to be generated and return the video URL. When the video generation is complete, the status will be “success” and the video URL will be returned. If the video is not generated within the timeout, it will return status “in_progress” to indicate the video is still processing.

Arguments

Accepts a JSON object with the following properties:
taskId
string
required
The ID of the video generation task to wait for.
timeoutSeconds
number
Maximum time to wait for task completion in seconds.

Response

Returns a JSON object with the following properties:
status
string
The status of the video generation operation. Returns “success” when the video is generated successfully, “in_progress” if the timeout is reached before completion, or “error” if the generation failed.
url
string
The URL that the generated video is accessible at (only present when status is “success”).
errorMessage
string
Error message describing what went wrong (only present when status is “error”).
If the timeout is reached before the video completes, the tool will return status: "in_progress" instead of throwing an error. This allows clients to handle the timeout gracefully and check again later if needed.

Usage

1

Define the Video service

Create a reusable service configuration that points to the MCP server and standardizes how you pass arguments and read results. This lets your agent easily interact with the Video tools in a consistent manner.
const videoService = {
    mcpServer: 'https://video.mcp.atxp.ai/',
    createVideoToolName: 'create_video',
    waitForVideoToolName: 'wait_for_video',
    description: 'ATXP Video MCP server',
    getCreateVideoArguments: (prompt: string) => ({ userPrompt: prompt }),
    getWaitForVideoArguments: (taskId: string) => ({ taskId, timeoutSeconds: 300 }),
    getCreateVideoResult: (result: any) => JSON.parse(result.content[0].text),
    getWaitForVideoResult: (result: any) => JSON.parse(result.content[0].text)
  };
2

Create an ATXP client

  • Using an ATXP account
  • Using a Base account
  • Using a Solana account
  • Using a Worldchain account
  • Using a Polygon account
Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
// Import the ATXP client SDK
import { atxpClient, ATXPAccount } from '@atxp/client';

// Read the ATXP account details from environment variables
const atxpConnectionString = process.env.ATXP_CONNECTION;

// Create a client using the `atxpClient` function
const client = await atxpClient({
  mcpServer: videoService.mcpServer,
  account: new ATXPAccount(atxpConnectionString),
});
3

Use the Video service in your agent

Call the Video tool by passing your natural-language instruction as the argument the getArguments method.Read the response using the getResult method.
const prompt = "Create a video of a cat riding a horse. Use a realistic style.";

try {
  const result = await client.callTool({
      name: videoService.createVideoToolName,
      arguments: videoService.getCreateVideoArguments(prompt),
  });
  const createVideoResult = videoService.getCreateVideoResult(result);
  console.log('Status:', createVideoResult.status);
  console.log('Task ID:', createVideoResult.taskId);

  const pollInterval = 15000; // 15 seconds

  while (true) {
    const result = await client.callTool({
      name: videoService.waitForVideoToolName,
      arguments: videoService.getWaitForVideoArguments(createVideoResult.taskId),
    });
    const waitForVideoResult = videoService.getWaitForVideoResult(result);
    console.log('Status:', waitForVideoResult.status);

    // Check if task is complete
    if (waitForVideoResult.status === 'success') {
      console.log(`${videoService.description} has generated a video!`);
      console.log('URL:', waitForVideoResult.url);
      break;
    }

    // Check if there was an error
    if (waitForVideoResult.status === 'error') {
      console.error(`${videoService.description} error:`, waitForVideoResult.errorMessage);
      process.exit(1);
    }

    // Status is 'in_progress', continue polling
    console.log(`${videoService.description} result pending (in_progress).`);
    await new Promise(resolve => setTimeout(resolve, pollInterval));
  }
} catch (error) {
  console.error(`Error with ${videoService.description}:`, error);
  process.exit(1);
}
You should see the result of the video creation printed in your console.
I