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.
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.
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.
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.
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.
Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
// Import the ATXP client SDKimport { atxpClient, ATXPAccount } from '@atxp/client';// Read the ATXP account details from environment variablesconst atxpConnectionString = process.env.ATXP_CONNECTION;// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account: new ATXPAccount(atxpConnectionString),});
Create a client using a Base account by importing the ATXP client SDK and other dependencies.
// Import the ATXP client SDK and Base accountimport { atxpClient } from '@atxp/client';import { BaseAccount } from '@atxp/base';// Read the Base account details from the environment variablesconst baseRpcUrl = process.env.BASE_RPC_URL;const basePrivateKey = process.env.BASE_PRIVATE_KEY;// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account: new BaseAccount(baseRpcUrl, basePrivateKey),});
Create a client using a Solana account by importing the ATXP client SDK and other dependencies.
// Import the ATXP client SDK and Solana accountimport { atxpClient } from '@atxp/client';import { SolanaAccount } from '@atxp/solana';// Read the Solana account details from the environment variablesconst solanaRpcUrl = process.env.SOLANA_RPC_URL;const solanaPrivateKey = process.env.SOLANA_PRIVATE_KEY;// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account: new SolanaAccount(solanaRpcUrl, solanaPrivateKey),});
Create a client using a Worldchain account with MiniKit integration.
// Import the ATXP client SDK and Worldchain account creatorimport { atxpClient } from '@atxp/client';import { createMiniKitWorldchainAccount } from '@atxp/worldchain';import { MiniKit } from '@worldcoin/minikit-js';// Create a Worldchain account using MiniKitconst account = await createMiniKitWorldchainAccount({ walletAddress: '0x1234...', // User's wallet address miniKit: MiniKit});// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account,});
Browser applications:
// Import the ATXP client SDK and Polygon browser accountimport { atxpClient } from '@atxp/client';import { PolygonBrowserAccount } from '@atxp/polygon';// Initialize the Polygon browser account with wallet providerconst account = await PolygonBrowserAccount.initialize({ provider: window.ethereum, // or any EIP-1193 provider walletAddress: '0x1234...', // User's wallet address});// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account,});
Server/CLI applications:
// Import the ATXP client SDK and Polygon server accountimport { atxpClient } from '@atxp/client';import { PolygonServerAccount } from '@atxp/polygon';// Read the Polygon account details from the environment variablesconst polygonRpcUrl = process.env.POLYGON_RPC_URL;const polygonPrivateKey = process.env.POLYGON_PRIVATE_KEY;// Create a Polygon server accountconst account = new PolygonServerAccount( polygonRpcUrl, polygonPrivateKey, 137 // Chain ID: 137 = Polygon mainnet, 80002 = Amoy testnet);// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: videoService.mcpServer, account,});
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.