> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atxp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Video

> Create and edit videos

## 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

<AccordionGroup>
  <Accordion title="create_video">
    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:

    <ParamField body="userPrompt" type="string" required>
      The natural language description of the video to generate
    </ParamField>

    ### Response

    Returns a JSON object with the following properties:

    <ResponseField name="status" type="string">
      The status of the video generation operation. Returns "success" when the video is generated successfully.
    </ResponseField>

    <ResponseField name="taskId" type="string">
      The task ID of the video generation operation.
    </ResponseField>
  </Accordion>

  <Accordion title="wait_for_video">
    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:

    <ParamField body="taskId" type="string" required>
      The ID of the video generation task to wait for.
    </ParamField>

    <ParamField body="timeoutSeconds" type="number">
      Maximum time to wait for task completion in seconds.
    </ParamField>

    ### Response

    Returns a JSON object with the following properties:

    <ResponseField name="status" type="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.
    </ResponseField>

    <ResponseField name="url" type="string">
      The URL that the generated video is accessible at (only present when status is "success").
    </ResponseField>

    <ResponseField name="errorMessage" type="string">
      Error message describing what went wrong (only present when status is "error").
    </ResponseField>

    <Note>
      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.
    </Note>
  </Accordion>
</AccordionGroup>

## Usage

<Steps>
  <Step title="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.

    ```typescript theme={null}
    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)
      };
    ```
  </Step>

  <Step title="Create an ATXP client">
    <Tabs>
      <Tab title="Using an ATXP account">
        Create a client using an <a href="/developers/build-agents/create-account" target="_blank">ATXP account</a> by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // 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),
        });
        ```
      </Tab>

      <Tab title="Using a Base account">
        Create a client using a Base account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Base account
        import { atxpClient } from '@atxp/client';
        import { BaseAccount } from '@atxp/base';

        // Read the Base account details from the environment variables
        const baseRpcUrl = process.env.BASE_RPC_URL;
        const basePrivateKey = process.env.BASE_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: videoService.mcpServer,
          account: new BaseAccount(baseRpcUrl, basePrivateKey),
        });
        ```
      </Tab>

      <Tab title="Using a Solana account">
        Create a client using a Solana account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Solana account
        import { atxpClient } from '@atxp/client';
        import { SolanaAccount } from '@atxp/solana';

        // Read the Solana account details from the environment variables
        const solanaRpcUrl = process.env.SOLANA_RPC_URL;
        const solanaPrivateKey = process.env.SOLANA_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: videoService.mcpServer,
          account: new SolanaAccount(solanaRpcUrl, solanaPrivateKey),
        });
        ```
      </Tab>

      <Tab title="Using a Worldchain account">
        Create a client using a Worldchain account with MiniKit integration.

        ```typescript theme={null}
        // Import the ATXP client SDK and Worldchain account creator
        import { atxpClient } from '@atxp/client';
        import { createMiniKitWorldchainAccount } from '@atxp/worldchain';
        import { MiniKit } from '@worldcoin/minikit-js';

        // Create a Worldchain account using MiniKit
        const account = await createMiniKitWorldchainAccount({
          walletAddress: '0x1234...', // User's wallet address
          miniKit: MiniKit
        });

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: videoService.mcpServer,
          account,
        });
        ```
      </Tab>

      <Tab title="Using a Polygon account">
        **Browser applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon browser account
        import { atxpClient } from '@atxp/client';
        import { PolygonBrowserAccount } from '@atxp/polygon';

        // Initialize the Polygon browser account with wallet provider
        const account = await PolygonBrowserAccount.initialize({
          provider: window.ethereum, // or any EIP-1193 provider
          walletAddress: '0x1234...', // User's wallet address
        });

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

        **Server/CLI applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon server account
        import { atxpClient } from '@atxp/client';
        import { PolygonServerAccount } from '@atxp/polygon';

        // Read the Polygon account details from the environment variables
        const polygonRpcUrl = process.env.POLYGON_RPC_URL;
        const polygonPrivateKey = process.env.POLYGON_PRIVATE_KEY;

        // Create a Polygon server account
        const account = new PolygonServerAccount(
          polygonRpcUrl,
          polygonPrivateKey,
          137 // Chain ID: 137 = Polygon mainnet, 80002 = Amoy testnet
        );

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: videoService.mcpServer,
          account,
        });
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="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.

    ```typescript theme={null}
    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);
    }
    ```

    <Check>
      You should see the result of the video creation printed in your console.
    </Check>
  </Step>
</Steps>
