Skip to main content
Glama

wait_video_generation_and_get_download_url

Monitors video generation progress and provides the download URL once processing is complete, enabling users to access their AI-generated videos.

Instructions

Polls until video generation completes and returns the download URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsYes

Implementation Reference

  • Tool registration using FastMCP @mcp.tool decorator with the exact name.
    @mcp.tool( name="wait_video_generation_and_get_download_url", description="Polls until video generation completes and returns the download URL.", )
  • The core handler function that polls the NoLang API for video status, handles progress reporting, different statuses, and returns the download URL upon completion.
    async def wait_video_generation_and_get_download_url( args: VideoWaitArgs, ctx: Context, ) -> VideoStatusResult: start = time.time() while time.time() - start < args.max_wait_time: try: status_response = await nolang_api.get_video_status(args.video_id) except httpx.HTTPStatusError as e: raise RuntimeError(format_http_error(e)) from e current_status = VideoStatusEnum(status_response.status) if current_status == VideoStatusEnum.RUNNING: await ctx.report_progress( progress=time.time() - start, total=args.max_wait_time ) # notify progress to client await asyncio.sleep(args.check_interval) continue if current_status == VideoStatusEnum.COMPLETED: await ctx.report_progress( progress=args.max_wait_time, total=args.max_wait_time ) # notify progress to client (100%) return VideoStatusResult( video_id=args.video_id, status=current_status, download_url=status_response.download_url, ) if current_status == VideoStatusEnum.FAILED: raise RuntimeError(f"Video generation failed. Video ID: {args.video_id}") # Unknown status – wait and retry await asyncio.sleep(args.check_interval) raise TimeoutError("Video generation did not complete within the time limit.")
  • Pydantic model defining the input parameters for the tool: video_id, max_wait_time, check_interval.
    class VideoWaitArgs(BaseModel): """Arguments for waiting for video generation completion.""" model_config = ConfigDict(extra="forbid") video_id: UUID = Field( ..., description="Video ID of the generation job", ) max_wait_time: int = Field( default=600, description="Maximum seconds to wait for generation completion", ge=1, le=3600, ) check_interval: int = Field(default=10, description="Interval (seconds) to check status", ge=1, le=60)
  • Pydantic model defining the output schema: video_id, status, and download_url.
    class VideoStatusResult(BaseModel): model_config = ConfigDict(extra="allow") video_id: UUID = Field(..., description="Unique identifier for the video") status: VideoStatusEnum = Field(..., description="Current status of the video") download_url: Optional[str] = Field(None, description="Signed URL for the finished MP4 file")
  • Enum used in the handler and output schema for video status values.
    class VideoStatusEnum(str, Enum): """Video generation status.""" RUNNING = "running" COMPLETED = "completed" FAILED = "failed" EXPIRED = "expired"

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/team-tissis/nolang-mcp'

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