Skip to main content
Glama

query_video_generation

Check the status of a video generation task using the provided Task ID. Save the output file to a specified directory relative to the base path configured in MiniMax MCP JS.

Instructions

Query the status of a video generation task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outputDirectoryNoThe directory to save the output file. `outputDirectory` is relative to `MINIMAX_MCP_BASE_PATH` (or `basePath` in config). The final save path is `${basePath}/${outputDirectory}`. For example, if `MINIMAX_MCP_BASE_PATH=~/Desktop` and `outputDirectory=workspace`, the output will be saved to `~/Desktop/workspace/`
taskIdYesThe Task ID to query. Should be the task_id returned by `generate_video` tool if `async_mode` is True.

Implementation Reference

  • Registration of the 'query_video_generation' MCP tool including inline Zod schema for parameters (taskId, outputDirectory) and the handler function that calls VideoAPI.queryVideoGeneration and formats the MCP response.
    private registerQueryVideoGenerationTool(): void {
      this.server.tool(
        'query_video_generation',
        'Query the status of a video generation task.',
        {
          taskId: z
            .string()
            .describe('The Task ID to query. Should be the task_id returned by `generate_video` tool if `async_mode` is True.'),
          outputDirectory: COMMON_PARAMETERS_SCHEMA.outputDirectory,
        },
        async (params) => {
          try {
            // No need to update configuration from request parameters in stdio mode
            const result = await this.videoApi.queryVideoGeneration(params);
    
            if (result.status === 'Success') {
              if (this.config.resourceMode === RESOURCE_MODE_URL) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Success. Video URL: ${result.video_url}`, 
                    },
                  ],
                };
              } else {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Success. Video saved as: ${result.video_path}`,
                    },
                  ],
                };
              }
            } else {
              return {
                content: [
                  {
                    type: 'text',
                    text: `Video generation task is still processing: Task ID: ${params.taskId}.`,
                  },
                ],
              };
            }
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Failed to query video generation: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
            };
          }
        },
      );
  • Core handler logic in VideoAPI class: queries MiniMax API /v1/query/video_generation for task status, retrieves file info if success, returns URL or downloads and saves the MP4 video file.
    async queryVideoGeneration(request: VideoGenerationQueryRequest): Promise<any> {
      const taskId = request.taskId;
    
      // Step 1: Get video generation status
      const response = await this.api.get<any>(`/v1/query/video_generation?task_id=${taskId}`);
      const status = response?.status;
      let fileId: string | null = null;
      if (status === 'Fail') {
        throw new MinimaxRequestError(`Video generation task failed, task ID: ${taskId}`);
      } else if (status === 'Success') {
        fileId = response?.file_id;
        if (!fileId) {
          throw new MinimaxRequestError(`File ID missing in success response, task ID: ${taskId}`);
        }
      } else {
        return {
          status,
        }
      }
    
      // Step 2: Get video result
      const fileResponse = await this.api.get<any>(`/v1/files/retrieve?file_id=${fileId}`);
      const downloadUrl = fileResponse?.file?.download_url;
    
      if (!downloadUrl) {
        throw new MinimaxRequestError(`Unable to get download URL for file ID: ${fileId}`);
      }
    
      // If URL mode, return URL directly
      const resourceMode = this.api.getResourceMode();
      if (resourceMode === RESOURCE_MODE_URL) {
        return {
          status,
          video_url: downloadUrl,
          task_id: taskId,
        };
      }
    
      // Step 3: Download and save video
      const outputPath = buildOutputFile(`video_${taskId}`, request.outputDirectory, 'mp4', true);
    
      try {
        const videoResponse = await requests.default.get(downloadUrl, { responseType: 'arraybuffer' });
    
        // Ensure directory exists
        const dirPath = path.dirname(outputPath);
        if (!fs.existsSync(dirPath)) {
          fs.mkdirSync(dirPath, { recursive: true });
        }
    
        // Save file
        fs.writeFileSync(outputPath, Buffer.from(videoResponse.data));
        return {
          status,
          video_path: outputPath,
          task_id: taskId,
        }
      } catch (error) {
        throw new MinimaxRequestError(`Failed to download or save video: ${String(error)}`);
      }
    }
  • TypeScript interface defining the input parameters for video generation query: taskId (string), inherits outputDirectory etc. from BaseToolRequest.
    export interface VideoGenerationQueryRequest extends BaseToolRequest {
      taskId: string;
    }
  • Wrapper method in MediaService that calls VideoAPI.queryVideoGeneration and formats REST response, used by mcp-rest-server.
    public async queryVideoGeneration(params: any): Promise<any> {
      this.checkInitialized();
      try {
        const result = await this.videoApi.queryVideoGeneration(params);
        if (result.status === 'Success') {
          if (this.config.resourceMode === RESOURCE_MODE_URL) {
            return {
            content: [
                {
                  type: 'text',
                  text: `Success. Video URL: ${result.video_url}`,
                },
              ],
            };
          } else {
            return {
              content: [
                {
                  type: 'text',
                  text: `Success. Video saved as: ${result.video_path}`,
                },
              ],
            };
          }
        } else {
          return {
            content: [
              {
                type: 'text',
                text: `Video generation task is still processing: Task ID: ${params.taskId}.`,
              },
            ],
          };
        }
      } catch (error) {
        throw this.wrapError('Failed to query video generation status', error);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it queries status without detailing behavioral traits like error handling, rate limits, or what the status response includes. It mentions the relationship to `generate_video` but doesn't explain if this is a read-only operation or has side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and every part earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (querying task status) and no output schema, the description is minimally adequate but lacks details on return values or error conditions. With no annotations, it should provide more behavioral context to be fully complete for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds no additional meaning beyond what's in the schema, such as clarifying parameter interactions or usage nuances, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('query') and resource ('status of a video generation task'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential alternatives like checking task status through other means, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning 'task_id returned by `generate_video` tool if `async_mode` is True,' suggesting when to use this tool. However, it lacks explicit guidance on when NOT to use it or alternatives for synchronous tasks, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/MiniMax-AI/MiniMax-MCP-JS'

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