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

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

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: imageService.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);
    console.log('URL:', waitForVideoResult.url);

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

    // Wait before next poll
    console.log(`${videoService.description} result pending.`);
    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.